-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
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
dataarray arithmetics restore removed coordinates in xarray 0.15 #3746
Comments
the issue here is that if you call In [13]: arr1_ = arr1.copy()
...: del arr1_.coords["x"]
...: del arr1_.coords["y"]
...: arr1_.coords, arr1_.indexes
Out[13]:
(Coordinates:
*empty*, y: Int64Index([0, 1], dtype='int64', name='y')
x: Int64Index([0, 1], dtype='int64', name='x')) Since #3481 the indexes are passed along in binary operations (such as multiplication) and will thus cause the coordinates reappear. Note that coordinates without indexes (non-dimension coordinates) will be removed properly. If we want to support this way of dropping coordinates we should update the indexes, explicitly or via For now the easiest way to properly remove coordinates is by using |
@keewis thanks for the quick reply. I wasn't aware the builtin |
I don't know whether or not this was supposed to work. Since there is a explicit |
Thanks for the clarification. I can confirm that |
IMO we should fix to remove associated indexes and issue a patch release. |
* Delete associated indexes when deleting coordinate variables. Fixes #3746 * review * fix tests
MCVE Code Sample
Expected Output
Problem Description
In xarray 0.15, the coordinates are restored when doing the multiplication:
Output of
xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.8.1 | packaged by conda-forge | (default, Jan 29 2020, 14:55:04)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.18.0-147.0.3.el8_1.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.3
xarray: 0.15.0
pandas: 1.0.0
numpy: 1.18.1
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: 2.3.2
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.2
cfgrib: None
iris: None
bottleneck: 1.3.1
dask: 2.10.1
distributed: 2.10.0
matplotlib: 3.1.3
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 45.1.0.post20200119
pip: 20.0.2
conda: None
pytest: 5.3.5
IPython: 7.12.0
sphinx: 2.3.1
The text was updated successfully, but these errors were encountered: