Open LunarLanding opened 2 years ago
This does look like a bug, here's another case:
In [78]:
...: >>> a = np.arange(0, 5, 1)
...: >>> b = np.linspace(0, 1, 5)
...: >>> ds = xr.Dataset({"a": ("x", a), "b": ("x", b)})
...: >>> ds
Out[78]:
<xarray.Dataset>
Dimensions: (x: 5)
Dimensions without coordinates: x
Data variables:
a (x) int64 0 1 2 3 4
b (x) float64 0.0 0.25 0.5 0.75 1.0
In [79]: ds.query(x="a > 2")
Out[79]:
<xarray.Dataset>
Dimensions: (x: 2)
Dimensions without coordinates: x
Data variables:
a (x) int64 3 4
b (x) float64 0.75 1.0
In [80]: ds.set_coords('a').query(x="a > 2")
Out[80]:
<xarray.Dataset>
Dimensions: (x: 2)
Coordinates:
a (x) int64 3 4
Dimensions without coordinates: x
Data variables:
b (x) float64 0.75 1.0
In [81]: ds.set_coords(['a','b']).query(x="a > 2")
# fails
What happened?
I make a dataset with some variables, and make them all coordinates. Then I try to query on the dataset. Error ensues.
What did you expect to happen?
No error.
Minimal Complete Verifiable Example
Relevant log output
Anything else we need to know?
If the dataset has one data variable, then the error does not happen.
Environment
INSTALLED VERSIONS
commit: None python: 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:25:59) [GCC 10.3.0] python-bits: 64 OS: Linux OS-release: 4.19.0-19-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1
xarray: 2022.3.0 pandas: 1.4.1 numpy: 1.22.3 scipy: 1.8.0 netCDF4: 1.5.8 pydap: None h5netcdf: 1.0.0 h5py: 3.6.0 Nio: None zarr: 2.11.1 cftime: 1.5.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.03.0 distributed: 2022.3.0 matplotlib: 3.5.1 cartopy: None seaborn: 0.11.2 numbagg: None fsspec: 2022.02.0 cupy: None pint: 0.18 sparse: 0.13.0 setuptools: 59.8.0 pip: 22.0.4 conda: 4.12.0 pytest: 7.1.1 IPython: 7.32.0 sphinx: None