Closed
Description
MCVE Code Sample
I optimistically tried passing a lambda to where
* to avoid another .pipe
. To my surprise it ran! But unfortunately it just ignored the lambda, as though all values were True.
In [1]: import xarray as xr
In [2]: import numpy as np
In [3]: da = xr.DataArray(np.random.rand(2,3))
In [4]: da.where(da > 0.5)
Out[4]:
<xarray.DataArray (dim_0: 2, dim_1: 3)>
array([[ nan, 0.71442406, nan],
[0.55748705, nan, nan]])
Dimensions without coordinates: dim_0, dim_1
# this should fail!
In [5]: da.where(lambda x: x > 0.5)
Out[5]:
<xarray.DataArray (dim_0: 2, dim_1: 3)>
array([[0.26085668, 0.71442406, 0.05816167],
[0.55748705, 0.15293073, 0.12766453]])
Dimensions without coordinates: dim_0, dim_1
Expected Output
Raise a TypeError
when passed the lambda
* (maybe that could work, but separate discussion)
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.8 (default, Aug 7 2019, 17:28:10)
[...]
python-bits: 64
OS: Linux
OS-release: [...]
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.utf8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: None
xarray: 0.14.1
pandas: 0.25.3
numpy: 1.18.1
scipy: 1.4.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.1.2
cartopy: None
seaborn: 0.10.0
numbagg: None
setuptools: 45.0.0
pip: 20.0.2
conda: None
pytest: 5.3.2
IPython: 7.11.1
sphinx: 2.3.1
Metadata
Metadata
Assignees
Labels
No labels