issues: 1611701140
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1611701140 | I_kwDOAMm_X85gEJuU | 7588 | xr.merge with compat="minimal" returns corrupted Dataset and causes __len__ to return wrong and possibly negative values. | 2466330 | closed | 0 | 4 | 2023-03-06T15:47:40Z | 2023-08-30T09:14:19Z | 2023-08-30T07:57:37Z | CONTRIBUTOR | What happened?When merging multiple datasets with the compat="minimal" option, coordinates whose variables are dropped due to incompatibility are still saved in the dataset's This is directly related to the bug described in issue 7405. As seen there, one result is that dropped coordinate still evaluates as being contained in the resulting dataset's At least one other (perhaps more severe) result of this bug is connected to the fact that the If a coordinate was dropped as a result of the merge, it is no longer part of the One instance where this causes immediate errors is when trying to print the resulting dataset. As part of the While this is undoubtedly only one of many places where the incorrect What did you expect to happen?To get a Dataset with the correct Minimal Complete Verifiable Example```Python import xarray as xr ds1 = xr.Dataset(coords={"foo": [1, 2, 3], "bar": 4}) ds2 = xr.Dataset(coords={"foo": [1, 2, 3], "bar": 5}) res = xr.merge([ds1, ds2], compat="minimal") # If the result is not captured in res, this will cause a ValueError as the interpreter attempts to print the result res.coords Coordinates:* foo (foo) int64 1 2 3res._coord_names {'foo', 'bar'}"bar" in res.coords # As shown in issue #7405. Note "bar" is not printed in res.coords, revealing an interesting disconnect in behaviors of different functions targeting a dataset's coordinates Trueres ValueError: len() should return >= 0``` MVCE confirmation
Relevant log output```Python
Anything else we need to know?No response Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
python-bits: 64
OS: Linux
OS-release: 5.10.16.3-microsoft-standard-WSL2
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None
xarray: 2023.2.0
pandas: 1.5.1
numpy: 1.24.2
scipy: 1.10.0
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: 2.13.6
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: 0.9.10.3
iris: None
bottleneck: 1.3.6
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: 2023.1.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 59.6.0
pip: 23.0.1
conda: None
pytest: 7.2.1
mypy: 1.0.1
IPython: 7.34.0
sphinx: None
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7588/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |