macromax.utils.array package
This module provides additional functionality to work with nd-arrays.
Submodules
macromax.utils.array.add_dims_on_right module
- macromax.utils.array.add_dims_on_right.add_dims_on_right(arr, new_axes_on_right=0, ndim=None)[source]
A function that returns a view with additional singleton dimensions on the right. This is useful to broadcast and expand on the left-hand side with an array of an arbitrary number of dimensions on the right-hand side.
- Parameters:
arr (
Union
[Complex
,Sequence
,ndarray
]) – The original array or sequence of numbers that can be converted to an array.new_axes_on_right (
int
) – (optional) The number of axes to add on the right hand side. Default: ndim - arr.ndim or 0 if the latter is not specified. If negative, singleton dimensions are removed from the right. This will fail if those on the right are not singleton dimensions.ndim (
Optional
[int
]) – (optional) The total number of axes of the returned view. Default: arr.ndim + new_axes_on_right
- Returns:
A view with ndim == arr.ndim + new_axes_on_right dimensions.
macromax.utils.array.vector_to_axis module
macromax.utils.array.word_align module
- macromax.utils.array.word_align.word_align(input_array, word_length=32)[source]
Returns a new array that is byte-aligned to words of length word_length bytes. This may be required for libraries such as pyfftw.
- Parameters:
input_array – The input array to align.
word_length (
int
) – The word length to align to. This must be an integer multiple of the dtype size.
- Returns:
A word-aligned array with the same contents and shape as input_array.