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 2099550299,I_kwDOAMm_X859JJhb,8666,Error unstacking array API compliant class,35968931,closed,0,,,0,2024-01-25T04:35:09Z,2024-01-26T16:06:02Z,2024-01-26T16:06:02Z,MEMBER,,,,"### What happened? Unstacking fails for array types that strictly follow the array API standard. ### What did you expect to happen? This obviously works fine with a normal numpy array. ### Minimal Complete Verifiable Example ```Python import numpy.array_api as nxp arr = nxp.asarray([[1, 2, 3], [4, 5, 6]], dtype=np.dtype('float32')) da = xr.DataArray( arr, coords=[(""x"", [""a"", ""b""]), (""y"", [0, 1, 2])], ) da stacked = da.stack(z=(""x"", ""y"")) stacked.indexes[""z""] stacked.unstack() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[65], line 8 6 stacked = da.stack(z=(""x"", ""y"")) 7 stacked.indexes[""z""] ----> 8 roundtripped = stacked.unstack() 9 arr.identical(roundtripped) File ~/Documents/Work/Code/xarray/xarray/util/deprecation_helpers.py:115, in _deprecate_positional_args.._decorator..inner(*args, **kwargs) 111 kwargs.update({name: arg for name, arg in zip_args}) 113 return func(*args[:-n_extra_args], **kwargs) --> 115 return func(*args, **kwargs) File ~/Documents/Work/Code/xarray/xarray/core/dataarray.py:2913, in DataArray.unstack(self, dim, fill_value, sparse) 2851 @_deprecate_positional_args(""v2023.10.0"") 2852 def unstack( 2853 self, (...) 2857 sparse: bool = False, 2858 ) -> Self: 2859 """""" 2860 Unstack existing dimensions corresponding to MultiIndexes into 2861 multiple new dimensions. (...) 2911 DataArray.stack 2912 """""" -> 2913 ds = self._to_temp_dataset().unstack(dim, fill_value=fill_value, sparse=sparse) 2914 return self._from_temp_dataset(ds) File ~/Documents/Work/Code/xarray/xarray/util/deprecation_helpers.py:115, in _deprecate_positional_args.._decorator..inner(*args, **kwargs) 111 kwargs.update({name: arg for name, arg in zip_args}) 113 return func(*args[:-n_extra_args], **kwargs) --> 115 return func(*args, **kwargs) File ~/Documents/Work/Code/xarray/xarray/core/dataset.py:5581, in Dataset.unstack(self, dim, fill_value, sparse) 5579 for d in dims: 5580 if needs_full_reindex: -> 5581 result = result._unstack_full_reindex( 5582 d, stacked_indexes[d], fill_value, sparse 5583 ) 5584 else: 5585 result = result._unstack_once(d, stacked_indexes[d], fill_value, sparse) File ~/Documents/Work/Code/xarray/xarray/core/dataset.py:5474, in Dataset._unstack_full_reindex(self, dim, index_and_vars, fill_value, sparse) 5472 if name not in index_vars: 5473 if dim in var.dims: -> 5474 variables[name] = var.unstack({dim: new_dim_sizes}) 5475 else: 5476 variables[name] = var File ~/Documents/Work/Code/xarray/xarray/core/variable.py:1684, in Variable.unstack(self, dimensions, **dimensions_kwargs) 1682 result = self 1683 for old_dim, dims in dimensions.items(): -> 1684 result = result._unstack_once_full(dims, old_dim) 1685 return result File ~/Documents/Work/Code/xarray/xarray/core/variable.py:1574, in Variable._unstack_once_full(self, dim, old_dim) 1571 reordered = self.transpose(*dim_order) 1573 new_shape = reordered.shape[: len(other_dims)] + new_dim_sizes -> 1574 new_data = reordered.data.reshape(new_shape) 1575 new_dims = reordered.dims[: len(other_dims)] + new_dim_names 1577 return type(self)( 1578 new_dims, new_data, self._attrs, self._encoding, fastpath=True 1579 ) AttributeError: 'Array' object has no attribute 'reshape' ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. - [X] Recent environment — the issue occurs with the latest version of xarray and its dependencies. ### Relevant log output _No response_ ### Anything else we need to know? It fails on the `arr.reshape` call, because the array API standard has reshape be a function, not a method. We do in fact have an array API-compatible version of `reshape` defined in `duck_array_ops.py`, it just apparently isn't yet used everywhere we call reshape. https://github.com/pydata/xarray/blob/037a39e249e5387bc15de447c57bfd559fd5a574/xarray/core/duck_array_ops.py#L363 ### Environment main branch of xarray, numpy 1.26.0","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8666/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1426383543,I_kwDOAMm_X85VBOK3,7232,ds.Coarsen.construct demotes non-dimensional coordinates to variables,35968931,closed,0,,,0,2022-10-27T23:39:32Z,2022-10-28T17:46:51Z,2022-10-28T17:46:51Z,MEMBER,,,,"### What happened? `ds.Coarsen.construct` demotes non-dimensional coordinates to variables ### What did you expect to happen? All variables that were coordinates before the coarsen.construct stay as coordinates afterwards. ### Minimal Complete Verifiable Example ```Python In [3]: da = xr.DataArray(np.arange(24), dims=[""time""]) ...: da = da.assign_coords(day=365 * da) ...: ds = da.to_dataset(name=""T"") In [4]: ds Out[4]: Dimensions: (time: 24) Coordinates: day (time) int64 0 365 730 1095 1460 1825 ... 6935 7300 7665 8030 8395 Dimensions without coordinates: time Data variables: T (time) int64 0 1 2 3 4 5 6 7 8 9 ... 14 15 16 17 18 19 20 21 22 23 In [5]: ds.coarsen(time=12).construct(time=(""year"", ""month"")) Out[5]: Dimensions: (year: 2, month: 12) Coordinates: day (year, month) int64 0 365 730 1095 1460 ... 7300 7665 8030 8395 Dimensions without coordinates: year, month Data variables: T (year, month) int64 0 1 2 3 4 5 6 7 8 ... 16 17 18 19 20 21 22 23 ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output _No response_ ### Anything else we need to know? _No response_ ### Environment `main` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7232/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 547523622,MDU6SXNzdWU1NDc1MjM2MjI=,3676,Merging dataArray into dataset using dataset method fails,35968931,closed,0,,,0,2020-01-09T14:46:49Z,2020-01-12T13:04:02Z,2020-01-12T13:04:02Z,MEMBER,,,,"While it's possible to merge a dataset and a dataarray object using the top-level `merge()` function, if you try the same thing with the `ds.merge()` method it fails. ```python import xarray as xr ds = xr.Dataset({'a': 0}) da = xr.DataArray(1, name='b') expected = xr.merge([ds, da]) # works fine print(expected) ds.merge(da) # fails ``` Output: ``` Dimensions: () Data variables: a int64 0 b int64 1 Traceback (most recent call last): File ""mwe.py"", line 6, in actual = ds.merge(da) File ""/home/tegn500/Documents/Work/Code/xarray/xarray/core/dataset.py"", line 3591, in merge fill_value=fill_value, File ""/home/tegn500/Documents/Work/Code/xarray/xarray/core/merge.py"", line 835, in dataset_merge_method objs, compat, join, priority_arg=priority_arg, fill_value=fill_value File ""/home/tegn500/Documents/Work/Code/xarray/xarray/core/merge.py"", line 548, in merge_core coerced = coerce_pandas_values(objects) File ""/home/tegn500/Documents/Work/Code/xarray/xarray/core/merge.py"", line 394, in coerce_pandas_values for k, v in obj.items(): File ""/home/tegn500/Documents/Work/Code/xarray/xarray/core/common.py"", line 233, in __getattr__ ""{!r} object has no attribute {!r}"".format(type(self).__name__, name) AttributeError: 'DataArray' object has no attribute 'items' ``` ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3676/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 463096652,MDU6SXNzdWU0NjMwOTY2NTI=,3073,Accidentally left a print statement,35968931,closed,0,,,0,2019-07-02T08:38:40Z,2019-07-02T14:16:43Z,2019-07-02T14:16:43Z,MEMBER,,,,"Somehow a rogue debugging print statement managed to sneak through to master in #2616! Line 121 of combine.py https://github.com/pydata/xarray/blob/e2c2264833ce7e861bbb930be44356e1510e13c3/xarray/core/combine.py#L121 should be deleted. @shoyer @dcherian","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3073/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue