flopscope.numpy.ndim
fnp.ndim(a)[flopscope source][numpy source]
Return the number of dimensions of an array.
Adapted from NumPy docs np.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
- ndarray.ndim equivalent method
- we.flops.shape dimensions of array
- ndarray.shape dimensions of array
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