issues: 1382661146
This data as json
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1382661146 | I_kwDOAMm_X85Sabwa | 7068 | xr.where overrides coordinate attributes with global attributes | 1991007 | closed | 0 | 1 | 2022-09-22T15:44:21Z | 2023-02-14T11:05:03Z | 2023-02-14T11:05:03Z | NONE | What happened?
What did you expect to happen?The coordinate attributes to remain unchanged. Minimal Complete Verifiable Example```Python import xarray as xr x_coord = xr.DataArray( [1, 2, 3], dims="x", attrs={"units": "m"} ) a = xr.DataArray( [1, 2, 3], dims="x", coords={"x": x_coord}, attrs={"units": "K"} ) res = xr.where(a > 1, a, 0, keep_attrs=True) assert res.coords["x"].attrs["units"] == "m" # Fails, overridden with "K" ``` MVCE confirmation
Relevant log outputNo response Anything else we need to know?Not sure if this is a duplicate of https://github.com/pydata/xarray/issues/2245. If so, feel free to close :) Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-1160.53.1.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: de_DE.UTF-8
LOCALE: ('de_DE', 'UTF-8')
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 2022.6.0
pandas: 1.5.0
numpy: 1.23.3
scipy: 1.9.1
netCDF4: 1.5.6
pydap: None
h5netcdf: None
h5py: 3.3.0
Nio: None
zarr: 2.12.0
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.2.1
cfgrib: None
iris: None
bottleneck: None
dask: 2022.9.1
distributed: 2022.9.1
matplotlib: 3.6.0
cartopy: None
seaborn: None
numbagg: None
fsspec: 2022.8.2
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.3.0
pip: 22.2.2
conda: None
pytest: 7.1.3
IPython: None
sphinx: None
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7068/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |