numpy.ma.shape

ma.shape(obj)[源代码]

返回数组的形状。

参数
aarray_like

输入数组。

返回
shape整数元组

形状元组的元素给出了相应数组维度的长度。

参见

len
ndarray.shape

等效数组方法。

实例

>>> np.shape(np.eye(3))
(3, 3)
>>> np.shape([[1, 2]])
(1, 2)
>>> np.shape([0])
(1,)
>>> np.shape(0)
()
>>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
(2,)
>>> a.shape
(2,)