-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
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:
import numpy as np
import dask.array as da
plain_numpy_array = np.arange(5)
masked_numpy_array = np.ma.array(np.arange(5), mask=[0, 1, 1, 0, 0])
dask_array = da.from_array(plain_numpy_array)
print(type(plain_numpy_array * dask_array))
print(type(masked_numpy_array * dask_array))output:
<class 'dask.array.core.Array'>
<class 'numpy.ma.core.MaskedArray'>
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:
- Dask version: 2.26.0
- Python version: 3.7.8
- Operating System: RHEL7.8
- Install method (conda, pip, source): miniconda