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 266133430,MDU6SXNzdWUyNjYxMzM0MzA=,1635,DataArray.argsort should be deleted,7441788,open,0,,,7,2017-10-17T13:52:54Z,2023-03-10T02:31:27Z,,CONTRIBUTOR,,,,"Originally posted to https://groups.google.com/forum/#!topic/xarray/wsxeiIPLhgM `DataArray.argsort()` appears to simply wrap the result of `DataArray.values.argsort()` in a same-shape `DataArray`. This is semantically nonsensical. If anything the index on the resulting `argsort()` values should simply be `range(len(da))`, but that adds little to the underlying numpy structure. And there's not much reason to have `da.argsort()` simply return the (raw) result of `da.values.argsort()`. So really `DataArray.argsort()` should simply be deleted. On the other hand a new function `DataArray.rank()` that wraps `da.values.argsort().argsort()` (note repeated call to `ndarray.argsort()`) in the structure of the original `DataArray` *would* make sense, and perhaps even be useful... (Note that I'm not claiming that `.argsort().argsort()` is the fastest way to calculate this, but it's probably good enough, at least for an initial implementation.)","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1635/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 572875480,MDU6SXNzdWU1NzI4NzU0ODA=,3810,"{DataArray,Dataset}.rank() should support an optional list of dimensions",7441788,open,0,,,10,2020-02-28T16:57:08Z,2021-11-19T15:09:10Z,,CONTRIBUTOR,,,,"`{DataArray,Dataset}.rank()` requires a single `dim`. Why not support an optional list of dimensions (defaulting to all)? ``` In [1]: import numpy as np, xarray as xr In [2]: d = xr.DataArray(np.arange(12).reshape((4,3)), dims=('abc', 'xyz')) In [3]: d Out[3]: array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 9, 10, 11]]) Dimensions without coordinates: abc, xyz In [4]: d.rank() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in ----> 1 d.rank() TypeError: rank() missing 1 required positional argument: 'dim' In [5]: d.rank(dim=('xyz', 'abc')) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) in ----> 1 d.rank(dim=('xyz', 'abc')) ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/dataarray.py in rank(self, dim, pct, keep_attrs) 3054 """""" 3055 -> 3056 ds = self._to_temp_dataset().rank(dim, pct=pct, keep_attrs=keep_attrs) 3057 return self._from_temp_dataset(ds) 3058 ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/dataset.py in rank(self, dim, pct, keep_attrs) 5295 """""" 5296 if dim not in self.dims: -> 5297 raise ValueError(""Dataset does not contain the dimension: %s"" % dim) 5298 5299 variables = {} TypeError: not all arguments converted during string formatting In [6]: xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 3.10.0-693.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.15.0 pandas: 1.0.1 numpy: 1.18.1 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: 0.8.0 h5py: 2.10.0 Nio: None zarr: None cftime: 1.0.4.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.11.0 distributed: 2.11.0 matplotlib: 3.1.3 cartopy: None seaborn: 0.10.0 numbagg: installed setuptools: 45.2.0.post20200209 pip: 20.0.2 conda: 4.8.2 pytest: None IPython: 7.12.0 sphinx: None ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3810/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 483028482,MDU6SXNzdWU0ODMwMjg0ODI=,3236,ENH: apply_ufunc logging or callback,7441788,open,0,,,3,2019-08-20T18:59:36Z,2021-07-21T10:00:51Z,,CONTRIBUTOR,,,,"With long-running (think hours) `apply_ufunc(..., vectorize=True)` calls, it would be nice to be able to have logging of the input non-core dims being evaluated, perhaps via a call-back.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3236/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 309098246,MDU6SXNzdWUzMDkwOTgyNDY=,2017,np.minimum.accumulate(da) doesn't work,7441788,open,0,,,7,2018-03-27T19:15:06Z,2021-07-04T03:20:18Z,,CONTRIBUTOR,,,,"#### Code Sample, a copy-pastable example if possible ``` In [1]: import numpy as np In [2]: import xarray as xr In [3]: np.minimum.accumulate(np.array([3,2,4,1])) Out[3]: array([3, 2, 2, 1], dtype=int32) In [4]: np.minimum.accumulate(xr.DataArray([3,2,4,1])) --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) in () ----> 1 np.minimum.accumulate(xr.DataArray([3,2,4,1])) ~\Anaconda3\lib\site-packages\xarray\core\arithmetic.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs) 49 'alternative, consider explicitly converting xarray objects ' 50 'to NumPy arrays (e.g., with `.values`).' ---> 51 .format(method, ufunc)) 52 53 if any(isinstance(o, SupportsArithmetic) for o in out): NotImplementedError: accumulate method for ufunc is not implemented on xarray objects, which currently only support the __call__ method. As an alternative, consider explicitly converting xarray objects to NumPy arrays (e.g., with `.values`). ``` #### Problem description I would expect this to work, like `xr.apply_ufunc(np.minimum.accumulate, xr.DataArray([3,2,4,1]))`: #### Expected Output ``` Out[4]: array([3, 2, 2, 1]) Dimensions without coordinates: dim_0 ``` #### Output of ``xr.show_versions()``
``` commit: None python: 3.6.4.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None xarray: 0.10.2 pandas: 0.22.0 numpy: 1.14.2 scipy: 1.0.0 netCDF4: None h5netcdf: 0.5.0 h5py: 2.7.1 Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.17.1 distributed: 1.21.3 matplotlib: 2.2.2 cartopy: None seaborn: 0.8.1 setuptools: 39.0.1 pip: 9.0.2 conda: 4.3.34 pytest: 3.4.2 IPython: 6.2.1 sphinx: 1.7.1 ```
Originally posted posted to https://groups.google.com/forum/#!topic/xarray/LiwxrJcJBwY. ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2017/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 207317762,MDU6SXNzdWUyMDczMTc3NjI=,1266,Coordinate type changing from string to object,7441788,open,0,,,2,2017-02-13T19:38:16Z,2020-10-27T16:33:46Z,,CONTRIBUTOR,,,,"Originally posted on https://groups.google.com/forum/#!topic/xarray/4k8ZAx998UU. I would expect `[2]`, `[3]`, and `[4]` to produce identical results, with coordinate `xyz` being of type `|S1` (in general `|Sn` where n is minimal to accommodate the coordinate values), not `object`. This behavior is observed with xarray versions 0.8.2 and 0.9.1. ``` Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] Type ""copyright"", ""credits"" or ""license"" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: from xarray import DataArray In [2]: DataArray([1.], dims=('xyz',), coords={'xyz': ['a']}) + \ ...: DataArray([5.], dims=('xyz',), coords={'xyz': ['a']}) Out[2]: array([ 6.]) Coordinates: * xyz (xyz) |S1 'a' In [3]: DataArray([1., 2.], dims=('xyz',), coords={'xyz': ['a', 'b']}) + \ ...: DataArray([5.], dims=('xyz',), coords={'xyz': ['a']}) Out[3]: array([ 6.]) Coordinates: * xyz (xyz) object 'a' In [4]: DataArray([1.], dims=('xyz',), coords={'xyz': ['a']}) + \ ...: DataArray([5., 6.], dims=('xyz',), coords={'xyz': ['a', 'b']}) Out[4]: array([ 6.]) Coordinates: * xyz (xyz) object 'a' ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1266/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 683657289,MDU6SXNzdWU2ODM2NTcyODk=,4363,Indexing a datetime64[ns] coordinate with a scalar datetime.date produces a KeyError,7441788,open,0,,,2,2020-08-21T15:54:16Z,2020-09-19T19:16:37Z,,CONTRIBUTOR,,,,"Indexing a `datetime64[ns]` coordinate with a scalar `datetime.date` produces a `KeyError` (`[6]`). Curiously, indexing with a `datetime.date` _slice_ does work (`[5]`). I would expect `[6]` to work just like `[4]`. This may well be related to (or a duplicate of) #3736, #4283, #4292, #4306, #4319, or #4370, but none of those actually mentions `datetime.date` objects, so I can't tell. ```python In [1]: import xarray as xr, pandas as pd, datetime as dt In [2]: x = xr.DataArray([1., 2., 3.], [('foo', pd.date_range('2010-01-01', periods=3))]) In [3]: x Out[3]: array([1., 2., 3.]) Coordinates: * foo (foo) datetime64[ns] 2010-01-01 2010-01-02 2010-01-03 In [4]: x.loc[dt.datetime(2010, 1, 1)] Out[4]: array(1.) Coordinates: foo datetime64[ns] 2010-01-01 In [5]: x.loc[dt.date(2010, 1, 1):dt.date(2010, 1, 3)] Out[5]: array([1., 2., 3.]) Coordinates: * foo (foo) datetime64[ns] 2010-01-01 2010-01-02 2010-01-03 In [6]: x.loc[dt.date(2010, 1, 1)] --------------------------------------------------------------------------- KeyError Traceback (most recent call last) in ----> 1 x.loc[dt.date(2010, 1, 1)] ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/dataarray.py in __getitem__(self, key) 196 labels = indexing.expanded_indexer(key, self.data_array.ndim) 197 key = dict(zip(self.data_array.dims, labels)) --> 198 return self.data_array.sel(**key) 199 200 def __setitem__(self, key, value) -> None: ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/dataarray.py in sel(self, indexers, method, tolerance, drop, **indexers_kwargs) 1152 method=method, 1153 tolerance=tolerance, -> 1154 **indexers_kwargs, 1155 ) 1156 return self._from_temp_dataset(ds) ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/dataset.py in sel(self, indexers, method, tolerance, drop, **indexers_kwargs) 2100 indexers = either_dict_or_kwargs(indexers, indexers_kwargs, ""sel"") 2101 pos_indexers, new_indexes = remap_label_indexers( -> 2102 self, indexers=indexers, method=method, tolerance=tolerance 2103 ) 2104 result = self.isel(indexers=pos_indexers, drop=drop) ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/coordinates.py in remap_label_indexers(obj, indexers, method, tolerance, **indexers_kwargs) 395 396 pos_indexers, new_indexes = indexing.remap_label_indexers( --> 397 obj, v_indexers, method=method, tolerance=tolerance 398 ) 399 # attach indexer's coordinate to pos_indexers ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/indexing.py in remap_label_indexers(data_obj, indexers, method, tolerance) 268 coords_dtype = data_obj.coords[dim].dtype 269 label = maybe_cast_to_coords_dtype(label, coords_dtype) --> 270 idxr, new_idx = convert_label_indexer(index, label, dim, method, tolerance) 271 pos_indexers[dim] = idxr 272 if new_idx is not None: ~/.conda/envs/build/lib/python3.7/site-packages/xarray/core/indexing.py in convert_label_indexer(index, label, index_name, method, tolerance) 188 else: 189 indexer = index.get_loc( --> 190 label.item(), method=method, tolerance=tolerance 191 ) 192 elif label.dtype.kind == ""b"": ~/.conda/envs/build/lib/python3.7/site-packages/pandas/core/indexes/datetimes.py in get_loc(self, key, method, tolerance) 620 else: 621 # unrecognized type --> 622 raise KeyError(key) 623 624 try: KeyError: datetime.date(2010, 1, 1) ``` **Environment**:
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08) [GCC 7.5.0] python-bits: 64 OS: Linux OS-release: 3.10.0-693.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.6 libnetcdf: 4.7.4 xarray: 0.16.0 pandas: 1.1.0 numpy: 1.19.1 scipy: 1.5.2 netCDF4: 1.5.4 pydap: None h5netcdf: 0.8.1 h5py: 2.10.0 Nio: None zarr: None cftime: 1.2.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.23.0 distributed: 2.23.0 matplotlib: 3.3.1 cartopy: None seaborn: 0.10.1 numbagg: installed pint: None setuptools: 49.6.0.post20200814 pip: 20.2.2 conda: 4.8.4 pytest: None IPython: 7.17.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4363/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 575564170,MDU6SXNzdWU1NzU1NjQxNzA=,3829,"{DataArray,Dataset} accessors with parameters",7441788,open,0,,,4,2020-03-04T16:41:55Z,2020-04-02T12:11:47Z,,CONTRIBUTOR,,,,"I would like to be able to create an DataArray accessor that takes parameters, e.g. `obj.weighted(w).sum(dim)`. This appears to be impossible using the existing `@register_{dataarray,dataset}_accessor`, which supports only accessors of the form `obj.weighted.sum(w, dim)`. To support the desired syntax, one could simply change https://github.com/pydata/xarray/blob/master/xarray/core/extensions.py#L36 from ``` accessor_obj = self._accessor(obj) ``` to ``` accessor_obj = partial(self._accessor, obj) ``` But that would break the current syntax (i.e. would require `obj.accessor().foo()`, so is clearly not acceptable. So any suggestions (short of simply creating slightly modified copies of `register_{dataarray,dataset}_accessor`) for supporting both the existing `obj.accessor.foo()` syntax as well as my desired `obj.accessor(*args, **kwargs).foo()` syntax?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3829/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue