You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an operation reduces the number of dimensions to zero, numpy returns a numpy scalar object:
In [33]: a = rand(10,10,10)
In [34]: a.sum()
Out[34]: 484.51400807908772
In [35]: _34.ndim
Out[35]: 0
In [36]: _34.shape
Out[36]: ()
For datarray, we can return scalars, but they will be plain numpy scalars, they won't have the extra datarray-specific fields (like labels, axes, ...). We can't add new fields to numpy scalars:
In [40]: _34.newfield=1
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'numpy.float64' object has no attribute 'newfield'
So this is not likely to change soon, but we want to record it here for later reference. If datarray is included in numpy, it may be easier to play with the scalar code to make datarray scalars have all the necessary fields.
The text was updated successfully, but these errors were encountered:
When an operation reduces the number of dimensions to zero, numpy returns a numpy scalar object:
For datarray, we can return scalars, but they will be plain numpy scalars, they won't have the extra datarray-specific fields (like labels, axes, ...). We can't add new fields to numpy scalars:
So this is not likely to change soon, but we want to record it here for later reference. If datarray is included in numpy, it may be easier to play with the scalar code to make datarray scalars have all the necessary fields.
The text was updated successfully, but these errors were encountered: