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
1371769156,I_kwDOAMm_X85Rw4lE,7030,Assigning with .loc indexing: implicit effect of dimension order?,6875882,closed,0,,,5,2022-09-13T17:19:07Z,2023-09-12T18:17:11Z,2023-09-12T18:17:11Z,CONTRIBUTOR,,,,"### What happened?
Assigning a DataArray to a subset of another DataArray seems to depend on the order of the dimensions
### What did you expect to happen?
I would expect xarray to automatically align the dimensions appropriately.
### Minimal Complete Verifiable Example
Example 1:
```python
from xarray import DataArray
from numpy import zeros, ones, arange
# Two arrays abc and acb, identical except for dimensional ordering
abc = DataArray(zeros((2, 3, 4)), dims=('a', 'b', 'c'))
acb = DataArray(zeros((2, 4, 3)), dims=('a', 'c', 'b'))
assert (abc == acb).all()
# Assign a subset
bc = DataArray(ones((3, 4)), dims=('b', 'c'))
abc.loc[dict(a=0)] = bc
acb.loc[dict(a=0)] = bc # ValueError: could not broadcast input array from shape (3,4) into shape (4,3)
```
Example 2:
Same as example 1, but instead of raising a ValueError, runs without error, but gives incorrect results because it ignores dimension order
```python
# This time, make b and c dimensions identical
abc = DataArray(zeros((2, 3, 3)), dims=('a', 'b', 'c'))
acb = DataArray(zeros((2, 3, 3)), dims=('a', 'c', 'b'))
assert (abc == acb).all()
# Assign a subset
bc = DataArray(arange(9).reshape(3, 3), dims=('b', 'c'))
abc.loc[dict(a=0)] = bc
acb.loc[dict(a=0)] = bc
assert (abc == acb).all() # Assertion error
```
### 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
INSTALLED VERSIONS
------------------
commit: None
python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('English_United States', '1252')
libhdf5: 1.12.1
libnetcdf: 4.8.1
xarray: 2022.6.0
pandas: 1.4.3
numpy: 1.23.1
scipy: 1.9.0
netCDF4: 1.6.0
pydap: None
h5netcdf: None
h5py: 3.7.0
Nio: None
zarr: None
cftime: 1.6.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.5.2
cartopy: None
seaborn: None
numbagg: None
fsspec: 2022.7.1
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 63.4.2
pip: 22.2.2
conda: 4.14.0
pytest: 7.1.2
IPython: 8.4.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7030/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
873713013,MDU6SXNzdWU4NzM3MTMwMTM=,5240,Coord name not set when `concat`ing along a DataArray,6875882,closed,0,,,4,2021-05-01T16:18:32Z,2021-08-23T17:00:39Z,2021-08-23T17:00:39Z,CONTRIBUTOR,,,,"```python
from xarray import DataArray, concat
a = DataArray([0], dims='a')
out = concat([a, a], dim=DataArray([0, 1], dims='b'))
print(out.coords)
```
> Coordinates:
> > None (b) int32 0 1
I would've expected the name of the new coordinate to be the name of the DataArray variable but instead it's `None`.
**Environment**:
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 04:59:43) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: English_United States.1252
libhdf5: None
libnetcdf: None
xarray: 0.17.0
pandas: 1.2.4
numpy: 1.20.2
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
pint: None
setuptools: 49.6.0.post20210108
pip: 21.1.1
conda: None
pytest: None
IPython: 7.23.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5240/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
828805728,MDU6SXNzdWU4Mjg4MDU3Mjg=,5022,Extracting `formatting_html` as a standalone library?,6875882,open,0,,,3,2021-03-11T06:23:04Z,2021-07-16T17:31:20Z,,CONTRIBUTOR,,,,"Hi, xarray is a superb library but my favorite icing on the cake is the out-of-the-box rich HTML display in Jupyter. I've been finding myself wanting the same thing for every class I use in python that is fundamentally a hierachically structured numerical dataset.
Has there been any discussion of generalizing the whole thing? I'd be happy to give it a shot myself, but I was hoping to pick your collective brains first, especially @benbovy and @jsignell, (who based on my very preliminary github sleuthing were early heavy-lifters?)","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5022/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
686495257,MDExOlB1bGxSZXF1ZXN0NDc0MDUyNjc1,4379,Use deepcopy recursively on numpy arrays,6875882,closed,0,,,12,2020-08-26T17:31:56Z,2020-08-27T15:58:49Z,2020-08-27T14:56:49Z,CONTRIBUTOR,,0,pydata/xarray/pulls/4379," - [x] Closes #4362
- [x] Tests added
- [x] Passes `isort . && black . && mypy . && flake8`
- [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst`
(Not sure this is worth noting in whats-new)","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4379/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull
683649612,MDU6SXNzdWU2ODM2NDk2MTI=,4362,Surprising deepcopy semantics with dtype='object',6875882,closed,0,,,4,2020-08-21T15:40:59Z,2020-08-27T14:56:48Z,2020-08-27T14:56:48Z,CONTRIBUTOR,,,,"```python
from copy import deepcopy
import numpy as np
import xarray as xr
class Dummy: pass
a0 = np.array([Dummy()])
a1 = deepcopy(a0)
print(a0[0] is a1[0]) # False, as expected
x0 = xr.DataArray(a0, dims='dummy')
x1 = deepcopy(x0)
print(x0.values[0] is x1.values[0]) # unexpectedly True
```
I *think* this is a bug, and would be fixed with an extra deepcopy around [here](https://github.com/pydata/xarray/blob/43a2a4bdf3a492d89aae9f2c5b0867932ff51cef/xarray/core/variable.py#L942)
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4362/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue