home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1047599975

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1047599975 I_kwDOAMm_X84-cRtn 5953 Selecting with MultiIndex raises a TypeError 34740232 closed 0 4160723   1 2021-11-08T15:39:10Z 2022-03-17T17:11:43Z 2022-03-17T17:11:43Z NONE      

What happened: After updating xarray to v0.20.1, some of my multi-index-based selection code raises a TypeError.

What you expected to happen: Selection should work in the case I am considering.

Minimal Complete Verifiable Example:

```python import xarray as xr import pandas as pd

da = xr.DataArray(data=[0, 1, 2, 3], dims=("x",)).reindex( {"x": pd.MultiIndex.from_product((["foo", "bar"], [0, 1]), names=("str", "int"))} ) print(da.sel(x=("foo", 1))) ```

Expected output (what I get with xarray 0.19.0):

<xarray.DataArray ()> array(1) Coordinates: x object ('foo', 1)

Actual output (with xarray 0.20.1):

Traceback (most recent call last): File "playgrounds/xarray_mwe.py", line 7, in <module> da.sel(x=("foo", 1)) File "/Users/leroyv/miniforge3/envs/eradiate/lib/python3.7/site-packages/xarray/core/dataarray.py", line 1337, in sel **indexers_kwargs, File "/Users/leroyv/miniforge3/envs/eradiate/lib/python3.7/site-packages/xarray/core/dataset.py", line 2505, in sel self, indexers=indexers, method=method, tolerance=tolerance File "/Users/leroyv/miniforge3/envs/eradiate/lib/python3.7/site-packages/xarray/core/coordinates.py", line 422, in remap_label_indexers obj, v_indexers, method=method, tolerance=tolerance File "/Users/leroyv/miniforge3/envs/eradiate/lib/python3.7/site-packages/xarray/core/indexing.py", line 120, in remap_label_indexers idxr, new_idx = index.query(labels, method=method, tolerance=tolerance) File "/Users/leroyv/miniforge3/envs/eradiate/lib/python3.7/site-packages/xarray/core/indexes.py", line 235, in query label_value, method=method, tolerance=tolerance TypeError: get_loc() got an unexpected keyword argument 'tolerance'

Anything else we need to know?: Nothing I'm aware of

Environment:

Output of <tt>xr.show_versions()</tt> (with xarray 0.19.0) INSTALLED VERSIONS ------------------ commit: None python: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 05:57:50) [Clang 11.1.0 ] python-bits: 64 OS: Darwin OS-release: 20.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: (None, 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 0.19.0 pandas: 1.3.4 numpy: 1.21.4 scipy: 1.7.1 netCDF4: 1.5.8 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.5.1.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2021.11.0 distributed: 2021.11.0 matplotlib: 3.4.3 cartopy: None seaborn: 0.11.2 numbagg: None pint: 0.18 setuptools: 58.5.3 pip: 21.3.1 conda: None pytest: 6.2.5 IPython: 7.29.0 sphinx: 4.2.0
Output of <tt>xr.show_versions()</tt> (with xarray 0.20.1) INSTALLED VERSIONS ------------------ commit: None python: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 05:57:50) [Clang 11.1.0 ] python-bits: 64 OS: Darwin OS-release: 20.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: (None, 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1 xarray: 0.20.1 pandas: 1.3.4 numpy: 1.21.4 scipy: 1.7.1 netCDF4: 1.5.8 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.5.1.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2021.11.0 distributed: 2021.11.0 matplotlib: 3.4.3 cartopy: None seaborn: 0.11.2 numbagg: None fsspec: 2021.11.0 cupy: None pint: 0.18 sparse: None setuptools: 58.5.3 pip: 21.3.1 conda: None pytest: 6.2.5 IPython: 7.29.0 sphinx: 4.2.0
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5953/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 77.242ms · About: xarray-datasette