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 2203250238,PR_kwDOAMm_X85qh2s8,8867,Avoid in-place multiplication of a large value to an array with small integer dtype,14371165,closed,0,,,3,2024-03-22T20:22:22Z,2024-03-29T15:26:38Z,2024-03-29T15:26:38Z,MEMBER,,0,pydata/xarray/pulls/8867,"Upstream numpy has become a bit more particular with which types you can use for inplace operations. This PR fixes ``` _______________ TestImshow.test_imshow_rgb_values_in_valid_range _______________ self = def test_imshow_rgb_values_in_valid_range(self) -> None: da = DataArray(np.arange(75, dtype=""uint8"").reshape((5, 5, 3))) _, ax = plt.subplots() > out = da.plot.imshow(ax=ax).get_array() /home/runner/work/xarray/xarray/xarray/tests/test_plot.py:2034: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/runner/work/xarray/xarray/xarray/plot/accessor.py:421: in imshow return dataarray_plot.imshow(self._da, *args, **kwargs) /home/runner/work/xarray/xarray/xarray/plot/dataarray_plot.py:1601: in newplotfunc primitive = plotfunc( /home/runner/work/xarray/xarray/xarray/plot/dataarray_plot.py:1853: in imshow alpha *= 255 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = masked_array( data=[[[1], [1], [1], [1], [1]], [[1], [1], ..., [1], [1], [1], [1]]], mask=False, fill_value=np.int64(999999), dtype=uint8) other = 255 def __imul__(self, other): """""" Multiply self by other in-place. """""" m = getmask(other) if self._mask is nomask: if m is not nomask and m.any(): self._mask = make_mask_none(self.shape, self.dtype) self._mask += m elif m is not nomask: self._mask += m other_data = getdata(other) other_data = np.where(self._mask, other_data.dtype.type(1), other_data) > self._data.__imul__(other_data) E numpy._core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'multiply' output from dtype('int64') to dtype('uint8') with casting rule 'same_kind' /home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/numpy/ma/core.py:4415: UFuncTypeError ``` Some curious behaviors seen while debugging: ```python alpha = np.array([1], dtype=np.int8) alpha *= 255 repr(alpha) # 'array([-1], dtype=int8)' alpha = np.array([1], dtype=np.int16) alpha *= 255 repr(alpha) # 'array([255], dtype=int16)' ``` xref: #8844","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8867/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 2034462507,PR_kwDOAMm_X85hniLB,8535,Filter null values before plotting,14371165,closed,0,,,3,2023-12-10T17:31:27Z,2023-12-13T15:44:55Z,2023-12-13T15:44:55Z,MEMBER,,0,pydata/xarray/pulls/8535,"I noticed that seaborn's plot was responding much faster than xarray's version with the same data. Turn's out seaborn drops any nulls: https://github.com/mwaskom/seaborn/blob/056413d7393e3daec597d430c076e45938d53376/seaborn/relational.py#L399 - [x] Tests added - [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8535/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1901520970,PR_kwDOAMm_X85amcNE,8203,Add T_DuckArray type hint to Variable.data,14371165,closed,0,,,3,2023-09-18T18:33:50Z,2023-09-19T17:41:28Z,2023-09-19T15:23:25Z,MEMBER,,0,pydata/xarray/pulls/8203,"The typing of Variable.data has been the very wide `Variable.data: Any` because of the difficulties defining the typing of a duckarray. This has led to confusion in downstream functions that uses `.data`. Sometimes arguments uses Any, np.typing.ArrayLike, np.ndarray or dask array typing which is unnecessarily narrow when xarray also supports for example sparse arrays or cupy arrays. This PR is a start at cleaning this up by defining a T_DuckArray typevar that symbolizes an array api compliant array. ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8203/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1522810384,PR_kwDOAMm_X85G1P52,7424,array api - Add tests for aggregations,14371165,open,0,,,3,2023-01-06T16:10:05Z,2023-04-20T13:37:13Z,,MEMBER,,1,pydata/xarray/pulls/7424," - [ ] Closes #7243 - [x] Tests added - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [ ] New functions/methods are listed in `api.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7424/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1638194068,PR_kwDOAMm_X85MxT6K,7667,Pull Request Labeler - Undo workaround sync-labels bug,14371165,closed,0,,,3,2023-03-23T19:45:31Z,2023-03-23T20:25:47Z,2023-03-23T20:23:03Z,MEMBER,,0,pydata/xarray/pulls/7667,"Seems https://github.com/actions/labeler/issues/112 is fixed. So using false should work. xref: #7431","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7667/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1490160140,PR_kwDOAMm_X85FGOVk,7374,Improve performance for backend datetime handling,14371165,closed,0,,,3,2022-12-11T16:01:05Z,2023-01-18T22:45:36Z,2023-01-13T14:50:53Z,MEMBER,,0,pydata/xarray/pulls/7374,"Was hunting some low-hanging performance fruits when reading in files. * Use Variable(..., fastpath=True) for cases when a Variable has been unpacked and modified slightly. * Don't check if variable is variable in decode_cf_variable * Don't import DataArray until necessary in as_compatible_data. * Add typing to touched files to make sure only Variables are used. - [ ] Closes #xxxx - [ ] Tests added - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [ ] New functions/methods are listed in `api.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7374/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1447049720,PR_kwDOAMm_X85CyQio,7285,Switch to T_DataArray in .coords,14371165,closed,0,,,3,2022-11-13T19:22:35Z,2022-11-23T17:48:25Z,2022-11-22T17:02:09Z,MEMBER,,0,pydata/xarray/pulls/7285,".coords were still using DataArray types switch to T_DataArray instead. - [x] Fixes mypy error seen in #7277 ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7285/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1376126962,PR_kwDOAMm_X84_G-4G,7046,Add helper for setting axis limits in facetgrid,14371165,closed,0,,,3,2022-09-16T15:47:17Z,2022-09-26T16:54:04Z,2022-09-25T15:29:01Z,MEMBER,,0,pydata/xarray/pulls/7046,"This PR adds a helper method that sets the same axis limits for all plots in a facetgrid. Helpful when * wanting specific limits for all plots. * you want to make sure all data is visible by simply using the method without any inputs. Which is not certain if sharex/sharey isn't used, relevant when using 3d plots as they don't work. Split up from #6778.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7046/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1035496539,PR_kwDOAMm_X84tpNcv,5896,Use importlib.resources to load files,14371165,closed,0,,,3,2021-10-25T19:32:30Z,2022-08-12T09:05:51Z,2021-10-25T21:18:18Z,MEMBER,,1,pydata/xarray/pulls/5896,"Following: https://importlib-resources.readthedocs.io/en/latest/migration.html#pkg-resources-resource-string - [ ] Closes #xxxx - [ ] Tests added - [ ] Passes `pre-commit run --all-files` - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [ ] New functions/methods are listed in `api.rst` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5896/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1326509734,PR_kwDOAMm_X848ikDG,6871,Handle None in assert_valid_xy,14371165,closed,0,,,3,2022-08-02T23:37:19Z,2022-08-12T08:59:59Z,2022-08-03T22:08:45Z,MEMBER,,0,pydata/xarray/pulls/6871,"Reduce diffs in #6778. * Handle `None` as the error message suggest should be possible * Add some typing while at it. mypy noticed that Hashable cannot use `"", "".join`-method so forcing them to `str` instead. Should be the same problem in #6856 but `Frozen` returns `Any` instead of `Hashable` for some reason.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6871/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1022061409,PR_kwDOAMm_X84s_Lme,5849,Simplify transpose in xr.dot,14371165,closed,0,,,3,2021-10-10T18:45:41Z,2021-10-11T06:16:05Z,2021-10-11T06:16:05Z,MEMBER,,0,pydata/xarray/pulls/5849,"Minor change inspired by #5365. - [x] Passes `pre-commit run --all-files` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5849/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 919595236,MDExOlB1bGxSZXF1ZXN0NjY4ODk3OTc0,5464,Allow plotting categorical data,14371165,closed,0,,,3,2021-06-12T15:51:34Z,2021-07-18T21:19:21Z,2021-06-21T17:45:39Z,MEMBER,,0,pydata/xarray/pulls/5464," - [x] Closes #4260 - [x] Tests added - [x] Passes `pre-commit run --all-files` - [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst` ```python a = xr.DataArray( [0, 1, 2], dims=(""dim_1""), coords=dict(dim_1=([""dim_1""], [""u"", ""v"", ""w""])), ) a.plot() ``` ![image](https://user-images.githubusercontent.com/14371165/121782053-0a23e180-cba8-11eb-9524-46bfe8c94b35.png) ```python a = xr.DataArray( [[0, 1, 2], [3, 4, 5]], dims=(""dim_0"", ""dim_1""), coords=dict(dim_0=([""dim_0""], [0, 1]), dim_1=([""dim_1""], [""u"", ""v"", ""w""])), ) a.plot() ``` ![image](https://user-images.githubusercontent.com/14371165/121781955-89fd7c00-cba7-11eb-8032-9b562f288621.png) ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5464/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 912816822,MDExOlB1bGxSZXF1ZXN0NjYyOTQzMzE1,5443,Fix invalid suggestion in error in apply_variable_ufunc,14371165,closed,0,,,3,2021-06-06T12:45:22Z,2021-07-02T16:06:47Z,2021-06-06T17:42:46Z,MEMBER,,0,pydata/xarray/pulls/5443,The suggestion appears to be copy/paste-friendly but the format was slightly off. ,"{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5443/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 933989796,MDExOlB1bGxSZXF1ZXN0NjgxMTEzMTI4,5556,Test test_missing.py without cftime installed,14371165,closed,0,,,3,2021-06-30T18:31:08Z,2021-07-02T16:05:53Z,2021-07-01T04:47:12Z,MEMBER,,0,pydata/xarray/pulls/5556,"The checks that didn't install cftime skipped the entire test_missing.py. Because cftime is also imported when importing the list of calenders `_CFTIME_CALENDERS`. Added also skips for the cases that assumed cftime was installed so they are correctly skipped. - [x] Passes `pre-commit run --all-files` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5556/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 916608188,MDExOlB1bGxSZXF1ZXN0NjY2MjU4ODU0,5456,Use checks from .pycompat in more places,14371165,closed,0,,,3,2021-06-09T19:34:46Z,2021-06-09T20:25:04Z,2021-06-09T20:01:24Z,MEMBER,,0,pydata/xarray/pulls/5456,Found a few more places where modules are being imported just for version checking.,"{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5456/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 780426518,MDExOlB1bGxSZXF1ZXN0NTUwMzIxOTU1,4771,Always force dask arrays to float in missing.interp_func,14371165,closed,0,,,3,2021-01-06T10:18:55Z,2021-05-18T18:17:30Z,2021-01-12T10:15:28Z,MEMBER,,0,pydata/xarray/pulls/4771,"`scipy.interpolate.interp1d` always forces float so make sure that `da.blockwise` understands that as well. - [x] Workaround for #4770 - [x] Tests added - [x] Passes `isort . && black . && mypy . && flake8` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4771/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 792639470,MDU6SXNzdWU3OTI2Mzk0NzA=,4839,Coordinate attributes are dropped when interpolating datasets,14371165,closed,0,,,3,2021-01-23T20:05:33Z,2021-04-27T07:00:08Z,2021-04-27T07:00:08Z,MEMBER,,,," **What happened**: When I was interpolating datasets I noticed that the coordinate variables disappeared. **What you expected to happen**: Coordinate attributes should be retained just like variables are. **Minimal Complete Verifiable Example**: ```python import numpy as np import xarray as xr names = np.core.defchararray.add(""long_variable_name"", np.arange(0, 2).astype(str)) coords = dict(time=np.array([0, 1])) data_vars = dict() for v in names: data_vars[v] = xr.Variable( ""time"", np.array([0, 1], dtype=int), attrs=dict(unit=""kg"") ) ds1 = xr.Dataset(data_vars=data_vars, coords=coords) ds1.attrs = { k: 2 for k in np.core.defchararray.add(""attr_"", np.arange(0, 3).astype(str)) } ds1.time.attrs.update(unit=""s"") # Print time: ds1.time Out[115]: array([0, 1]) Coordinates: * time (time) int32 0 1 Attributes: unit: s # Interpolate: ds1 = ds1.interp( time=np.array([0, 0.5, 1, 2]), assume_sorted=True, method=""linear"", kwargs=dict(fill_value=""extrapolate""), ) # Print interpolated time, units are lost: ds1.time Out[117]: array([0. , 0.5, 1. , 2. ]) Coordinates: * time (time) float64 0.0 0.5 1.0 2. ``` **Anything else we need to know?**: **Environment**:
Output of xr.show_versions() xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little libhdf5: 1.10.4 libnetcdf: None xarray: 0.16.2 pandas: 1.2.0 numpy: 1.17.5 scipy: 1.4.1 netCDF4: None pydap: None h5netcdf: None h5py: 2.10.0 Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2020.12.0 distributed: 2020.12.0 matplotlib: 3.3.2 cartopy: None seaborn: 0.11.1 numbagg: None pint: None setuptools: 51.1.2.post20210112 pip: 20.3.3 conda: 4.9.2 pytest: 6.2.1 IPython: 7.19.0 sphinx: 3.4.3
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4839/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue