MCPcopy Index your code
hub / github.com/numpy/numpy / shape

Function shape

numpy/_core/fromnumeric.py:2123–2168  ·  view source on GitHub ↗

Return the shape of an 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 : ``

(a)

Source from the content-addressed store, hash-verified

2121
2122@array_function_dispatch(_shape_dispatcher)
2123def shape(a):
2124 """
2125 Return the shape of an array.
2126
2127 Parameters
2128 ----------
2129 a : array_like
2130 Input array.
2131
2132 Returns
2133 -------
2134 shape : tuple of ints
2135 The elements of the shape tuple give the lengths of the
2136 corresponding array dimensions.
2137
2138 See Also
2139 --------
2140 len : ``len(a)`` is equivalent to ``np.shape(a)[0]`` for N-D arrays with
2141 ``N>=1``.
2142 ndarray.shape : Equivalent array method.
2143
2144 Examples
2145 --------
2146 >>> import numpy as np
2147 >>> np.shape(np.eye(3))
2148 (3, 3)
2149 >>> np.shape([[1, 3]])
2150 (1, 2)
2151 >>> np.shape([0])
2152 (1,)
2153 >>> np.shape(0)
2154 ()
2155
2156 >>> a = np.array([(1, 2), (3, 4), (5, 6)],
2157 ... dtype=[('x', 'i4'), ('y', 'i4')])
2158 >>> np.shape(a)
2159 (3,)
2160 >>> a.shape
2161 (3,)
2162
2163 """
2164 try:
2165 result = a.shape
2166 except AttributeError:
2167 result = asarray(a).shape
2168 return result
2169
2170
2171def _compress_dispatcher(condition, a, axis=None, out=None):

Callers 3

_rcMethod · 0.90
sizeFunction · 0.70

Calls 1

asarrayFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…