We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example:
import xarray as xr import numpy as np data = np.random.rand(4, 3) locs = np.arange(3.) times = np.arange(4.) foo = xr.DataArray(data, coords=[times, locs], dims=["time", "space"]) foo
When trying to do an in-place modification of the coordinate values
foo.coords['time'] += 10.
I get
ValueError: Cannot assign to the .values attribute of dimension coordinate a.k.a IndexVariable 'time'. Please use DataArray.assign_coords, Dataset.assign_coords or Dataset.assign as appropriate.
However, when looking at the values of the coordinate, they seem to have been modified by the operation:
commit: None python: 3.7.7 (default, May 7 2020, 21:25:33) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-66-generic 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: None
xarray: 0.16.2 pandas: 1.2.0 numpy: 1.19.4 scipy: 1.5.3 netCDF4: None pydap: None h5netcdf: None h5py: 3.1.0 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: 3.2.2 cartopy: None seaborn: None numbagg: None pint: 0.16.1 setuptools: 49.6.0.post20201009 pip: 20.3.3 conda: 4.9.2 pytest: 6.1.2 IPython: 7.19.0 sphinx: 3.3.0
The text was updated successfully, but these errors were encountered:
Thanks for the report!
This definitely seems like a bug. I confirmed that it is still present in xarray v0.17.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Example:
When trying to do an in-place modification of the coordinate values
I get
However, when looking at the values of the coordinate, they seem to have been modified by the operation:

Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.7 (default, May 7 2020, 21:25:33)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-66-generic
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: None
xarray: 0.16.2
pandas: 1.2.0
numpy: 1.19.4
scipy: 1.5.3
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.1.0
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: 3.2.2
cartopy: None
seaborn: None
numbagg: None
pint: 0.16.1
setuptools: 49.6.0.post20201009
pip: 20.3.3
conda: 4.9.2
pytest: 6.1.2
IPython: 7.19.0
sphinx: 3.3.0
The text was updated successfully, but these errors were encountered: