brainpy.math.size#

brainpy.math.size(a, axis=None)[source]#

Return the number of elements along a given axis.

Parameters:
  • a (array_like) – Input data.

  • axis (int, optional) – Axis along which the elements are counted. By default, give the total number of elements.

Returns:

element_count – Number of elements along the specified axis.

Return type:

int

See also

shape

dimensions of array

Array.shape

dimensions of array

Array.size

number of elements in array

Examples

>>> a = brainpy.math.array([[1,2,3], [4,5,6]])
>>> brainpy.math.size(a)
6
>>> brainpy.math.size(a, 1)
3
>>> brainpy.math.size(a, 0)
2