flopscope.numpy.shape
fnp.shape(a)[flopscope source][numpy source]
Return the shape of an array.
Adapted from NumPy docs np.shape
Cost
0
Flopscope Context
Return shape of array.
Parameters
- a:array_like
Input array.
Returns
- shape:tuple of ints
The elements of the shape tuple give the lengths of the corresponding array dimensions.
See also
- len
len(a)is equivalent to flops.shape(a)[0] for N-D arrays withN>=1. - ndarray.shape Equivalent array method.
Examples
>>> import flopscope.numpy as fnp
>>> flops.shape(flops.eye(3))
(3, 3)
>>> flops.shape([[1, 3]])
(1, 2)
>>> flops.shape([0])
(1,)
>>> flops.shape(0)
()>>> a = flops.array([(1, 2), (3, 4), (5, 6)],
... dtype=[('x', 'i4'), ('y', 'i4')])
>>> flops.shape(a)
(3,)
>>> a.shape
(3,)