>>> np.shape(np.eye(3))
(3, 3)
>>> np.shape([[1, 2]])
(1, 2)
>>> np.shape([0])
(1,)
>>> np.shape(0)
()
import numpy as np
arr = np.array([1,2,3])
arr.shape
>>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
(2,)
>>> a.shape
(2,)
numpy.shape(array_name)
a = np.arange(3)
b = np.arange(12).reshape((3, 4))
c = np.arange(24).reshape((2, 3, 4))
# it returns the length of each dimension (=size function of MATLAB)
print(a.shape) # (3,)
print(b.shape) # (3, 4)
print(c.shape) # (2, 3, 4)