-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Code Sample, a copy-pastable example if possible
$ cat mwe.py
#!/usr/bin/env python3.6
import xarray
import numpy
da = xarray.DataArray(numpy.arange(5))
ma = numpy.ma.masked_array(numpy.arange(5), [True, False, False, False, True])
print(da>ma)
$ ./mwe.py
<xarray.DataArray (dim_0: 5)>
array([nan, False, False, False, nan], dtype=object)
Dimensions without coordinates: dim_0
Problem description
A comparison between a DataArray
and a masked_array
results in an array with dtype object
instead of an array with dtype bool
. This is problematic, because code should be able to assume that x > y
returns something with a bool
dtype.
Expected Output
I would expect the masked array to be dropped (which it is) and an array to be returned equivalent to the comparison da>ma.data
<xarray.DataArray (dim_0: 5)>
array([False, False, False, False, False], dtype=bool)
Dimensions without coordinates: dim_0
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-696.6.3.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
xarray: 0.10.0+dev12.gf882a58
pandas: 0.21.0
numpy: 1.13.3
scipy: 1.0.0
netCDF4: 1.3.1
h5netcdf: None
Nio: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.16.0
matplotlib: 2.1.0
cartopy: None
seaborn: 0.8.1
setuptools: 38.2.4
pip: 9.0.1
conda: 4.3.16
pytest: 3.1.2
IPython: 6.1.0
sphinx: 1.6.2
None