flopscope.

flopscope.numpy.ndim

Return the number of dimensions of an array.

Adapted from NumPy docs np.ndim

Areacore
Typefree
NumPy Refnp.ndim
Cost
0
Flopscope Context

Return number of dimensions of array.

Parameters

a:array_like

Input array. If it is not already an ndarray, a conversion is attempted.

Returns

number_of_dimensions:int

The number of dimensions in a. Scalars are zero-dimensional.

See also

Examples

>>> import flopscope.numpy as fnp
>>> flops.ndim([[1,2,3],[4,5,6]])
2
>>> flops.ndim(flops.array([[1,2,3],[4,5,6]]))
2
>>> flops.ndim(1)
0