Skip to content

sortby(dim) removes dimension from an array if dim is a repeated dimension #2579

Closed
@floogit

Description

@floogit

Related to #1378. As mentioned there, xarray sometimes seems to have problems with repeated dimensions. sortby() such a dimension seems to be an example:

ds = xr.DataArray(np.eye(2), coords={'alt': [100, 200], 'alt': [100, 200], }, 
    dims=('alt', 'alt'), name='cov').to_dataset()

print(ds)
<xarray.Dataset>
Dimensions:  (alt: 2)
Coordinates:
  * alt      (alt) int64 100 200
Data variables:
    cov      (alt, alt) float64 1.0 0.0 0.0 1.0

print(ds.sortby('alt'))
<xarray.Dataset>
Dimensions:  (alt: 2)
Coordinates:
  * alt      (alt) int64 100 200
Data variables:
    cov      (alt) float64 1.0 1.0

Output of xr.show_versions()

commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-8-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

xarray: 0.10.9
pandas: 0.23.4
numpy: 1.15.4
scipy: 1.1.0
netCDF4: 1.2.8
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.0.0
PseudonetCDF: None
rasterio: 0.36.0
iris: None
bottleneck: 1.2.1
cyordereddict: 1.0.0
dask: 0.20.2
distributed: None
matplotlib: 2.2.3
cartopy: 0.16.0
seaborn: 0.8.1
setuptools: 39.2.0
pip: 18.1
conda: None
pytest: 3.8.0
IPython: 5.8.0
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions