brainpy.math.shape#

brainpy.math.shape(a)[source]#

Return the shape of an array.

Parameters:

a (array_like) – Input array.

Returns:

shape – The elements of the shape tuple give the lengths of the corresponding array dimensions.

Return type:

tuple of ints

See also

len

len(a) is equivalent to np.shape(a)[0] for N-D arrays with N>=1.

ndarray.shape

Equivalent array method.

Examples

>>> brainpy.math.shape(brainpy.math.eye(3))
(3, 3)
>>> brainpy.math.shape([[1, 3]])
(1, 2)
>>> brainpy.math.shape([0])
(1,)
>>> brainpy.math.shape(0)
()