nums.core.array.utils module
-
class
nums.core.array.utils.
OrderedGrid
(shape, block_shape, order, block_order=None)[source] Bases:
object
-
nums.core.array.utils.
normalize_axis_index
(axis, ndim)[source] - Parameters
axis (int) – The un-normalized index of the axis. Can be negative
ndim (int) – The number of dimensions of the array that axis should be normalized against
- Returns
normalized_axis – The normalized axis index, such that 0 <= normalized_axis < ndim
- Return type
int
- Raises
AxisError – If the axis index is invalid, when -ndim <= axis < ndim is false.
Examples
>>> normalize_axis_index(0, ndim=3) 0 >>> normalize_axis_index(1, ndim=3) 1 >>> normalize_axis_index(-1, ndim=3) 2
>>> normalize_axis_index(3, ndim=3) Traceback (most recent call last): ... AxisError: axis 3 is out of bounds for array of dimension 3 >>> normalize_axis_index(-4, ndim=3, msg_prefix='axes_arg') Traceback (most recent call last): ... AxisError: axes_arg: axis -4 is out of bounds for array of dimension 3