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 1284475176,I_kwDOAMm_X85Mj4ko,6726,Long import time,34740232,closed,0,,,9,2022-06-25T07:01:18Z,2022-10-28T16:25:41Z,2022-10-28T16:25:41Z,NONE,,,,"### What is your issue? Importing the xarray package takes a significant amount of time. For instance: ``` ❯ time python -c ""import xarray"" python -c ""import xarray"" 1.44s user 0.52s system 132% cpu 1.476 total ``` compared to others ``` ❯ time python -c ""import pandas"" python -c ""import pandas"" 0.45s user 0.35s system 177% cpu 0.447 total ❯ time python -c ""import scipy"" python -c ""import scipy"" 0.29s user 0.23s system 297% cpu 0.175 total ❯ time python -c ""import numpy"" python -c ""import numpy"" 0.29s user 0.43s system 313% cpu 0.229 total ❯ time python -c ""import datetime"" python -c ""import datetime"" 0.05s user 0.00s system 99% cpu 0.051 total ``` I am obviously not surprised that importing xarray takes longer than importing Pandas, Numpy or the datetime module, but 1.5 s is something you clearly notice when it is done *e.g.* by a command-line application. I inquired about import performance and found out about a [lazy module loader proposal by the Scientific Python community](https://scientific-python.org/specs/spec-0001/). AFAIK SciPy uses a similar system to populate its namespaces without import time penalty. Would it be possible for xarray to use delayed imports when relevant?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6726/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 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): ``` 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 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 xr.show_versions() (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 xr.show_versions() (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