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
Whilst trying to fix #5559 I noticed that xarray.testing.assert_equal (and xarray.testing.assert_equal) don't behave well with wrapped duck-typed arrays.
Firstly, they can give unhelpful AssertionError messages:
These are different, but not because the array values are different. At the moment .values is converting the wrapped array type by stripping the units too - it might be better to check the type of the wrapped array first, then use .values to compare. Or could we even do duck-typed testing by delegating via expected.data.equals(actual.data)? (EDIT: I don't think a .equals() method exists in the numpy API, but you could do the equivalent of assert all(expected.data == actual.data)
Secondly, given that we coerce before comparison, I think it's possible that assert_equal could say two different wrapped duck-type arrays are equal when they are not, just because np.asarray() coerces them to the same values.
Whilst trying to fix #5559 I noticed that
xarray.testing.assert_equal
(andxarray.testing.assert_equal
) don't behave well with wrapped duck-typed arrays.Firstly, they can give unhelpful
AssertionError
messages:These are different, but not because the array values are different. At the moment
.values
is converting the wrapped array type by stripping the units too - it might be better to check the type of the wrapped array first, then use.values
to compare. Or could we even do duck-typed testing by delegating viaexpected.data.equals(actual.data)
? (EDIT: I don't think a.equals()
method exists in the numpy API, but you could do the equivalent ofassert all(expected.data == actual.data)
Secondly, given that we coerce before comparison, I think it's possible that
assert_equal
could say two different wrapped duck-type arrays are equal when they are not, just becausenp.asarray()
coerces them to the same values.EDIT2: Looks like there is some discussion here
The text was updated successfully, but these errors were encountered: