-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arithmetic with numpy arrays: inconsistency depending on mask #6734
Comments
This appears to be an instance of numpy/numpy#15200, now that Dask Arrays more closely follow a NEP-13/18-style type hierarchy after #6393. If that is the case, then I would believe this is fully an upstream issue in NumPy. To check, what result to you get when you reverse the order of multiplication? |
Thanks @jthielen. If the order of multiplication is reversed, we do indeed get dask arrays for both cases. I've also used your # Masks in different places.
wm = WrappedArray(np.ma.masked_array([1, 3, 5], mask=[False, False, True]), test=2)
m = np.ma.masked_array([2, 0, 1], mask=[False, True, False])
print(wm * m)
print(m * wm) output:
So it looks like I should close this and subscribe to numpy/numpy#15200 instead? |
Thanks for following up. Are we agreed that numpy/numpy#15200 is the root culprit and this can be closed? |
Closing this on the assumption that the problem is with |
What happened:
If I multiply a plain numpy array by a dask array, I get a dask array. But if I multiply a numpy masked array by a dask array, I get a numpy masked array.
What you expected to happen:
I would expect to either get a dask array in both cases, or the type of my first operand in both cases.
Minimal Complete Verifiable Example:
output:
Anything else we need to know?:
This relates to #4441, and I note the advice at #4441 (comment) to explicitly convert the numpy arrays to dask arrays before the arithmetic operation. I am attempting to do this for Iris (SciTools/iris#3790) but, while teasing out the details of that, we noticed this inconsistency between plain numpy arrays and masked numpy arrays. I don't think the inconsistency was noted at #4441, and it possibly throws a new light on it?
Environment:
The text was updated successfully, but these errors were encountered: