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
When using DataArray/Dataset.isel with drop=True with a scalar DataArray as indexer (see example) resulting scalar coordinates do not get dropped.
When using an integer the behavior is as expected.
What did you expect to happen?
I expect that using a scalar DataArray behaves the same as an integer.
Minimal Complete Verifiable Example
importxarrayasxrda=xr.DataArray([1, 2, 3], dims="x", coord={"k": ("x", [0, 1, 2])})
# <xarray.DataArray (x: 3)># array([1, 2, 3])# Coordinates:# k (x) int32 0 1 2da.isel({"x": 1}, drop=True)
# works# <xarray.DataArray ()># array(2)da.isel({"x": xr.DataArray(1)}, drop=True)
# does not drop "k" coordinate# <xarray.DataArray ()># array(2)# Coordinates:# k int32 1
Relevant log output
No response
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: 4fbca23
python: 3.9.6 | packaged by conda-forge | (default, Jul 6 2021, 08:46:02) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('de_DE', 'cp1252')
libhdf5: 1.10.6
libnetcdf: 4.7.4
Thanks for the report @headtr1ck, I see that it is a regression bug introduced in #5692 when refactoring _isel_fancy (drop is ignored now, it shouldn't).
What happened?
When using
DataArray/Dataset.isel
withdrop=True
with a scalar DataArray as indexer (see example) resulting scalar coordinates do not get dropped.When using an integer the behavior is as expected.
What did you expect to happen?
I expect that using a scalar DataArray behaves the same as an integer.
Minimal Complete Verifiable Example
Relevant log output
No response
Anything else we need to know?
No response
Environment
INSTALLED VERSIONS
commit: 4fbca23
python: 3.9.6 | packaged by conda-forge | (default, Jul 6 2021, 08:46:02) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('de_DE', 'cp1252')
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.18.2.dev76+g3a7e7ca2.d20210706
pandas: 1.3.0
numpy: 1.21.0
scipy: 1.7.0
netCDF4: 1.5.6
pydap: installed
h5netcdf: 0.11.0
h5py: 3.3.0
Nio: None
zarr: 2.8.3
cftime: 1.5.0
nc_time_axis: 1.3.1
PseudoNetCDF: installed
cfgrib: None
iris: 2.4.0
bottleneck: 1.3.2
dask: 2021.06.2
distributed: 2021.06.2
matplotlib: 3.4.2
cartopy: 0.19.0.post1
seaborn: 0.11.1
numbagg: 0.2.1
fsspec: 2021.06.1
cupy: None
pint: 0.17
sparse: 0.12.0
setuptools: 49.6.0.post20210108
pip: 21.3.1
conda: None
pytest: 6.2.4
IPython: None
sphinx: None
The text was updated successfully, but these errors were encountered: