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 1900706633,I_kwDOAMm_X85xSntJ,8200,Wrong fallback version number when using PyInstaller,31126826,closed,0,,,3,2023-09-18T11:13:53Z,2023-09-18T12:14:10Z,2023-09-18T12:08:04Z,CONTRIBUTOR,,,,"### What is your issue? I'm trying to bundle some code using Xarray with PyInstaller. As a MRE, consider the following file: ```python # test.py import pandas as pd import xarray as xr print(xr.__version__) pd.DataFrame({'a': range(10)}).to_xarray() ``` and the following command-line to build and run the Pyinstaller executable: ```shell pyinstaller test.py && dist/test/test ``` --- Ideally, I would have expected the printed version to be `2023.8.0` (as when running the script without Pyinstaller). The fallback `9999` from https://github.com/pydata/xarray/blob/b08a9d868febc0c6aa0944d654ec92d833a70c37/xarray/__init__.py#L55 would also have done the job. Unfortunately, the actual version number is `'999'` which make the following pandas code to fail with: ``` Traceback (most recent call last): File ""test.py"", line 4, in pd.DataFrame({'a': range(10)}).to_xarray() File ""pandas/core/generic.py"", line 3243, in to_xarray File ""pandas/compat/_optional.py"", line 161, in import_optional_dependency ImportError: Pandas requires version '2022.03.0' or newer of 'xarray' (version '999' currently installed). ``` --- As a workaround, I added the line ```python xr.__version__ = ""9999"" ``` in my `test.py` file...
Versions ``` INSTALLED VERSIONS ------------------ commit: None python: 3.9.17 (main, Jul 5 2023, 20:41:20) [GCC 11.2.0] python-bits: 64 OS: Linux OS-release: 6.2.0-32-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: ('fr_FR', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2023.8.0 pandas: 2.1.0 numpy: 1.26.0 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None fsspec: None cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 58.1.0 pip: 23.0.1 conda: None pytest: None mypy: None IPython: None sphinx: None ```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8200/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 666270493,MDU6SXNzdWU2NjYyNzA0OTM=,4275,Interpolation along dimension with a single element,31126826,open,0,,,3,2020-07-27T12:52:35Z,2022-05-21T20:50:29Z,,CONTRIBUTOR,,,,"Let me consider a DataArray with a dimension containing a single element: ```python In [1]: import numpy as np In [2]: import xarray as xr In [3]: da = xr.DataArray(np.linspace(0.0, 100.0, 101).reshape(1, 101), coords=[('x', [1.0]), ('y', np.linspace(0.0, 1.0, 101))]) ``` Asking `x=1.0` in `interp` fails. More precisely, the 2D interpolation returns a NaN ```python In [5]: da.interp(x=1.0, y=0.4) /opt/anaconda3/lib/python3.7/site-packages/scipy/interpolate/interpolate.py:2533: RuntimeWarning: invalid value encountered in true_divide (grid[i + 1] - grid[i])) Out[5]: array(nan) Coordinates: x float64 1.0 y float64 0.4 ``` and the 1D interpolation returns a `ValueError`: ```python In [6]: da.interp(x=1.0) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) in ----> 1 da.interp(x=1.0) ... ValueError: x and y arrays must have at least 2 entries ``` I understand why the interpolation is impossible in an array with a single element. However, this behavior breaks my assumption that `interp` is a superset of `sel`, meaning that it gives the same result as `sel` for all inputs that are valid inputs for `sel` (except for a possible int to float type conversion). Here, I would expect `da.interp(x=1.0)` to give me the same result as `da.sel(x=1.0)`. What do you think of this corner case?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4275/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 589632313,MDU6SXNzdWU1ODk2MzIzMTM=,3910,In-place addition of arrays with the same coords but in a different order,31126826,closed,0,,,7,2020-03-28T18:27:58Z,2020-06-24T14:41:06Z,2020-06-24T14:41:06Z,CONTRIBUTOR,,,,"I have two DataArrays with the same dimension, but the index is in a different order. Adding them with `A + B` works fine, but the in-place addition fails. #### MCVE Code Sample ```python import numpy as np import xarray as xr n = 5 d1 = np.arange(n) np.random.shuffle(d1) A = xr.DataArray(np.ones(n), coords=[('dim', d1)]) d2 = np.arange(n) np.random.shuffle(d2) B = xr.DataArray(np.ones(n), coords=[('dim', d2)]) print(A + B) A += B ``` #### Expected Output `A = A + B` is working fine. I would expect `A += B` to do the same. #### Problem Description The in-place addition `A += B` fails: ``` Traceback (most recent call last): File ""/home/matthieu/xarray-test.py"", line 15, in A += B File ""/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 2619, in func with self.coords._merge_inplace(other_coords): File ""/opt/anaconda3/envs/xarray-tests/lib/python3.8/contextlib.py"", line 113, in __enter__ return next(self.gen) File ""/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/coordinates.py"", line 140, in _merge_inplace variables, indexes = merge_coordinates_without_align( File ""/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/merge.py"", line 328, in merge_coordinates_withou t_align return merge_collected(filtered, prioritized) File ""/opt/anaconda3/envs/xarray-tests/lib/python3.8/site-packages/xarray/core/merge.py"", line 210, in merge_collected raise MergeError( xarray.core.merge.MergeError: conflicting values for index 'dim' on objects to be combined: first value: Int64Index([1, 2, 0, 3, 4], dtype='int64', name='dim') second value: Int64Index([4, 2, 3, 1, 0], dtype='int64', name='dim') ``` #### Versions
Output of `xr.show_versions()` INSTALLED VERSIONS ------------------ commit: None python: 3.8.2 (default, Mar 26 2020, 15:53:00) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.19.112-1-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: fr_FR.UTF-8 libhdf5: None libnetcdf: None xarray: 0.15.0 pandas: 1.0.3 numpy: 1.18.1 scipy: None 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: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 46.1.1.post20200323 pip: 20.0.2 conda: None pytest: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3910/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 601185984,MDExOlB1bGxSZXF1ZXN0NDA0NDgzMTc2,3976,Proposal for better error message about in-place operation,31126826,closed,0,,,2,2020-04-16T15:46:56Z,2020-06-24T14:41:06Z,2020-06-24T14:41:06Z,CONTRIBUTOR,,0,pydata/xarray/pulls/3976,"Trying to make error message slightly more informative when the user might expect automatic alignment with in-place operation. - [X] Closes #3910 - [ ] Tests added - [X] Passes `isort -rc . && black . && mypy . && flake8` - [ ] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3976/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 547091670,MDU6SXNzdWU1NDcwOTE2NzA=,3674,Multi-index with categorical values,31126826,closed,0,,,7,2020-01-08T20:43:04Z,2020-03-13T19:55:07Z,2020-03-13T19:55:07Z,CONTRIBUTOR,,,,"Building a dataset from pandas with a multi-index with categorical values: ```python import pandas as pd cat = pd.CategoricalDtype(categories=['foo', 'bar', 'baz']) i1 = pd.Series(['foo', 'bar'], dtype=cat) i2 = pd.Series(['bar', 'bar'], dtype=cat) df = pd.DataFrame({'i1': i1, 'i2': i2, 'values': [1, 2]}) ds = df.set_index(['i1', 'i2']).to_xarray() print(ds) ``` Expected output: ``` Dimensions: (i1: 2, i2: 1) Coordinates: * i1 (i1) object 'foo' 'bar' * i2 (i2) object 'bar' Data variables: values (i1, i2) int64 1 2 ``` Actual output: ``` Dimensions: (i1: 3, i2: 3) Coordinates: * i1 (i1) object 'foo' 'bar' 'baz' * i2 (i2) object 'foo' 'bar' 'baz' Data variables: values (i1, i2) float64 nan 1.0 nan nan 2.0 nan nan nan nan ``` It is not wrong, but it is inconsistent with the non-categorical case (which gives the expected output above) and the single-index case (no filling with NaNs for single index). #### Output of ``xr.show_versions()``
INSTALLED VERSIONS ------------------ commit: None python: 3.8.0 (default, Nov 6 2019, 21:49:08) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.19.91-1-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: fr_FR.UTF-8 libhdf5: None libnetcdf: None xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.4 scipy: None 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: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 44.0.0.post20200106 pip: 19.3.1 conda: None pytest: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3674/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 580646897,MDExOlB1bGxSZXF1ZXN0Mzg3ODE0OTU0,3860,Fix multi-index with categorical values.,31126826,closed,0,,,2,2020-03-13T14:44:59Z,2020-03-13T19:55:07Z,2020-03-13T19:55:07Z,CONTRIBUTOR,,0,pydata/xarray/pulls/3860,"@fujiisoup Would you mind reviewing this PR? The bug was actually straightforward. - [X] Closes #3674 - [X] Tests added - [X] Passes `isort -rc . && black . && mypy . && flake8` - [X] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3860/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 546727720,MDU6SXNzdWU1NDY3Mjc3MjA=,3669,Fail to sel() when index comes from categorical pandas Series,31126826,closed,0,,,3,2020-01-08T09:00:20Z,2020-01-25T22:38:20Z,2020-01-25T22:38:20Z,CONTRIBUTOR,,,,"Dear xarray team, Thank you very much for your work on this useful package. Here is a bug I just found in my code. #### MCVE Code Sample Creating a Dataset from pandas when the coordinate is a categorical series: ```python import pandas as pd ind = pd.Series(['foo', 'bar'], dtype='category') df = pd.DataFrame({'ind': ind, 'values': [1, 2]}) df = df.set_index('ind') ds = df.to_xarray() print(ds.sel(ind='foo')) ``` #### Expected Output When `ind` is not categorical, the code returns the expected output: ``` Dimensions: () Coordinates: ind print(ds.sel(ind='foo')) File ""/opt/anaconda3/envs/issue/lib/python3.8/site-packages/xarray/core/dataset.py"", line 2013, in sel pos_indexers, new_indexes = remap_label_indexers( File ""/opt/anaconda3/envs/issue/lib/python3.8/site-packages/xarray/core/coordinates.py"", line 39 1, in remap_label_indexers pos_indexers, new_indexes = indexing.remap_label_indexers( File ""/opt/anaconda3/envs/issue/lib/python3.8/site-packages/xarray/core/indexing.py"", line 260, in remap_label_indexers idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) File ""/opt/anaconda3/envs/issue/lib/python3.8/site-packages/xarray/core/indexing.py"", line 179, in convert_label_indexer indexer = index.get_loc( TypeError: get_loc() got an unexpected keyword argument 'tolerance' ``` #### Output of ``xr.show_versions()``
commit: None python: 3.8.0 (default, Nov 6 2019, 21:49:08) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.19.91-1-MANJARO machine: x86_64 processor: byteorder: little LC_ALL: None LANG: fr_FR.UTF-8 LOCALE: fr_FR.UTF-8 libhdf5: None libnetcdf: None xarray: 0.14.1 pandas: 0.25.3 numpy: 1.17.4 scipy: None 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: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None setuptools: 44.0.0.post20200106 pip: 19.3.1 conda: None pytest: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3669/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue