shape#
- named_arrays.shape(a)#
Compute the shape of the given array.
In
numpy, the shape of an array is atupleof integers. For this package, each axis is characterized by a name instead of its position, so the shape is adictwhere the keys are the axis names and the values are number of elements along each axis.If
ais an arbitrarily-nested structure (dict,list,tuple, ordataclassesinstance), the result is thebroadcast_shapes()of the shapes of all the array-like leaves, so a container of compatible arrays reports their combined broadcasted shape.- Parameters:
a (int | float | complex | ndarray | Quantity | AbstractArray) – The array, or nested structure of arrays, to compute the shape of.
- Return type:
Examples
import named_arrays as na x = na.arange(0, 5, axis="x") y = na.arange(0, 3, axis="y") # the broadcasted shape of every array-like leaf na.shape({"foo": x, "bar": y})
{'x': 5, 'y': 3}