issues: 1473329967
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1473329967 | I_kwDOAMm_X85X0Tsv | 7350 | Coordinate variable gains coordinate on subset | 221526 | closed | 0 | 5 | 2022-12-02T19:18:14Z | 2022-12-05T22:56:30Z | 2022-12-05T22:56:30Z | CONTRIBUTOR | What happened?When subsetting a DataArray along a dimension down to a single item, the other coordinate variables gain this scalar coordinate. What did you expect to happen?Coordinate variables should not have their coordinates changed. Minimal Complete Verifiable Example```Python import numpy as np import xarray as xr lat = np.array([25, 35, 45]) lon = np.array([-105, -95, -85, -75]) time = np.array([0, 1]) data = np.arange(lat.size * lon.size * time.size) test_data = xr.DataArray(data.reshape((time.size, lat.size, lon.size)), coords=dict(lat=lat, lon=lon, time=time), dims=('time', 'lat', 'lon')) print(test_data.lat.coords) # Only 'lat' print(test_data.isel(time=0).lat.coords) # Has both 'lat' and 'time' pritn(test_data.isel(time=[0, 1]).lat.coords) # Only 'lat' ``` MVCE confirmation
Relevant log outputNo response Anything else we need to know?This occurs with both the latest 2022.11.0 release and current main. Environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:31:57) [Clang 14.0.6 ]
python-bits: 64
OS: Darwin
OS-release: 21.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.8.1
xarray: 2022.11.0
pandas: 1.5.2
numpy: 1.23.5
scipy: 1.9.3
netCDF4: 1.6.2
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: 0.9.10.2
iris: None
bottleneck: 1.3.5
dask: 2022.6.1
distributed: 2022.6.1
matplotlib: 3.6.2
cartopy: 0.21.0
seaborn: None
numbagg: None
fsspec: 2022.11.0
cupy: None
pint: 0.20.1
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.5.1
pip: 22.3.1
conda: None
pytest: 7.2.0
IPython: 8.6.0
sphinx: 5.3.0
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7350/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |