to_array_shape

sofia_redux.toolkit.utilities.func.to_array_shape(value, shape, dtype=None)[source]

Broadcast an array to the desired shape.

Converts an array or value to a numpy.ndarray broadcasting in the reverse order of the desired shape. For example, if shape is equal to (1, 2, 3, 4), then you may broadcast any of the following shapes to the desired shape:

(4,)
(3, 4)
(2, 3, 4)
(1, 2, 3, 4)
Parameters:
value

The value to broadcast

shapearray_like of int

The desired shape

dtypetype, optional

Convert the final array to a specific data type.

Returns:
numpy.ndarray

Output array of shape shape.