Skip to content
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

Indexing with an empty sequence results in an exception #2882

Closed
mdavezac opened this issue Apr 10, 2019 · 0 comments · Fixed by #2883
Closed

Indexing with an empty sequence results in an exception #2882

mdavezac opened this issue Apr 10, 2019 · 0 comments · Fixed by #2883
Labels

Comments

@mdavezac
Copy link
Contributor

Code Sample, a copy-pastable example if possible

A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you:
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

# Your code here
da = DataArray(np.arange(12).reshape((3, 4)), dims=['x', 'y'])
da[{'x': [0]}]  # Okay
da[{'x': []}] # error 

Problem description

Indexing with an empty list results in an exception.

Expected Output

It should return a dataarray with an axis of length zero.

Output of xr.show_versions()

# Paste the output here xr.show_versions() here commit: 2c10d14 python: 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)] python-bits: 64 OS: Darwin OS-release: 18.5.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_GB.UTF-8 LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 libhdf5: None libnetcdf: None

xarray: 0.12.1+4.g2c10d144.dirty
pandas: 0.24.2
numpy: 1.16.2
scipy: 1.2.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: None
distributed: None
matplotlib: 3.0.3
cartopy: None
seaborn: None
setuptools: 41.0.0
pip: 19.0.3
conda: None
pytest: 4.3.1
IPython: 7.4.0
sphinx: None

@mdavezac mdavezac changed the title empty Indexing with an empty sequence results in an exception Apr 10, 2019
mdavezac added a commit to ImperialCollegeLondon/xarray that referenced this issue Apr 10, 2019
@shoyer shoyer added the bug label Apr 10, 2019
shoyer pushed a commit that referenced this issue Apr 12, 2019
* Indexing with an empty array

Closes #2882

* Adds 2882 resolution to whats-new.rst

* Create empty indexing array directly

* assert xxx -> asset_identical
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants