nums.core.array.utils module

class nums.core.array.utils.OrderedGrid(shape, block_shape, order, block_order=None)[source]

Bases: object

index_iterator()[source]
Return type

Iterator[Tuple]

nums.core.array.utils.addr2idx(addr, shape)[source]
nums.core.array.utils.block_shape_from_subscript(subscript, block_shape)[source]
nums.core.array.utils.broadcast(a_shape, b_shape)[source]
nums.core.array.utils.broadcast_block_shape(a_shape, b_shape, a_block_shape)[source]
nums.core.array.utils.broadcast_shape(a_shape, b_shape)[source]
nums.core.array.utils.broadcast_shape_to(from_shape, to_shape)[source]
nums.core.array.utils.broadcast_shape_to_alt(from_shape, to_shape)[source]
nums.core.array.utils.broadcastable(a_shape, b_shape, a_block_shape, b_block_shape)[source]
nums.core.array.utils.can_broadcast_shape_to(from_shape, to_shape)[source]
nums.core.array.utils.can_broadcast_shapes(a_shape, b_shape)[source]
nums.core.array.utils.get_bop_output_type(op_name, dtype_a, dtype_b)[source]
nums.core.array.utils.get_reduce_output_type(op_name, dtype)[source]
nums.core.array.utils.get_slices(total_size, batch_size, order, reverse_blocks=False)[source]
nums.core.array.utils.get_uop_output_type(op_name, dtype)[source]
nums.core.array.utils.idx2addr(index, shape)[source]
nums.core.array.utils.is_1d(shape)[source]
nums.core.array.utils.is_array_like(obj)[source]
nums.core.array.utils.is_bool(val, type_test=False)[source]
nums.core.array.utils.is_complex(val, type_test=False)[source]
nums.core.array.utils.is_float(val, type_test=False)[source]
nums.core.array.utils.is_index_subscript(val)[source]
nums.core.array.utils.is_int(val, type_test=False)[source]
nums.core.array.utils.is_regular_subscript(val)[source]
nums.core.array.utils.is_scalar(val)[source]
nums.core.array.utils.is_supported(val, type_test=False)[source]
nums.core.array.utils.is_type(type_test, val, types)[source]
nums.core.array.utils.is_uint(val, type_test=False)[source]
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
nums.core.array.utils.np_tensordot_param_test(as_, nda, bs, ndb, axes)[source]
nums.core.array.utils.shape_from_block_array(arr)[source]
nums.core.array.utils.slice_sel_to_index_list(slice_selection)[source]
nums.core.array.utils.to_dtype_cls(dtype)[source]
nums.core.array.utils.translate_index_list(from_index_list, from_shape, to_shape)[source]