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
The code below leads to an awkward result when combining two DataArrays. Despite the fact that both d1 and d2 are defined as (11,6) arrays, a multiplication results in a (3,2) array.
The origin of this behaviour is that xarray cannot match the coordinate variables because of differences in precision between float32/64. Although they look the same:
In [24]: d1.lat.data[1]
Out[24]: 0.1In [25]: d2.lat.data[1]
Out[25]: 0.1
Therefore the result of the multiplication is a (3,2) array because only the coordinates that match between d1 and d2 are returned.
A bit similar issue has already been raised in this issue where tolerance in alignment between coordinate variables was discussed.
Expected Output
You could argue that this behavior is the 'expected' output from this operation. However, from the "principle of least astonishment" I would argue that it would be better to either include a tolerance in matching coordinate variables, or to raise a TypeError indicating the incompatibility in the coordinate variables.
The results above were obtained with xarray 0.11.0 and numpy 1.14.2, while this behaviour did not occur in xarray version 0.10.4 with the same numpy version.
The text was updated successfully, but these errors were encountered:
Code sample
The code below leads to an awkward result when combining two DataArrays. Despite the fact that both d1 and d2 are defined as (11,6) arrays, a multiplication results in a (3,2) array.
Problem description
The origin of this behaviour is that xarray cannot match the coordinate variables because of differences in precision between float32/64. Although they look the same:
They are not:
Except for the coordinate values at 0.0, 0.5, 1.0 which can be both represented with full accuracy in f32 and f64:
Therefore the result of the multiplication is a (3,2) array because only the coordinates that match between d1 and d2 are returned.
A bit similar issue has already been raised in this issue where tolerance in alignment between coordinate variables was discussed.
Expected Output
You could argue that this behavior is the 'expected' output from this operation. However, from the "principle of least astonishment" I would argue that it would be better to either include a tolerance in matching coordinate variables, or to raise a TypeError indicating the incompatibility in the coordinate variables.
The results above were obtained with xarray 0.11.0 and numpy 1.14.2, while this behaviour did not occur in xarray version 0.10.4 with the same numpy version.
The text was updated successfully, but these errors were encountered: