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 1325665237,I_kwDOAMm_X85PBAvV,6866,Confusing terminologies and some errors in the official documentation,49091585,closed,0,,,4,2022-08-02T10:48:07Z,2023-08-23T14:20:23Z,2023-08-23T14:20:23Z,NONE,,,,"### What happened? To note, I'm using the stable version(2022.6.0). First, I'm confused that both `dimension coordinate`/`non-dimension coordinate` and `index coordinate`/`non-index coordinate` appear in the documentation(search to see), but they seem to be the same thing. Second, I found that there are some errors in the documentation: - It says that ""[The index associated with dimension name x can be retrieved by arr.indexes[x]. By construction, `len(arr.dims) == len(arr.indexes)`](https://docs.xarray.dev/en/stable/user-guide/terminology.html#:~:text=The%20index%20associated%20with%20dimension%20name%20x%20can%20be%20retrieved%20by%20arr.indexes%5Bx%5D.%20By%20construction%2C%20len(arr.dims)%20%3D%3D%20len(arr.indexes))"", which is inconsistent with actual behavior. See example code below: ```python In [0]: import xarray as xr, numpy as np In [1]: arr = xr.DataArray(np.zeros((2, 3)), dims=['x', 'y'], coords={'x': ['a', 'b']}) In [2]: assert len(arr.dims) == len(arr.indexes), f""{len(arr.dims)=}, {len(arr.indexes)=}"" --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) in ----> 1 assert len(arr.dims) == len(arr.indexes), f""{len(arr.dims)=}, {len(arr.indexes)=}"" AssertionError: len(arr.dims)=2, len(arr.indexes)=1 In [3]: arr.indexes Out[3]: Indexes: x: Index(['a', 'b'], dtype='object', name='x') ``` It seems that `arr.indexes` only returns indexes of dimensions that have coordinates. However, it's possible to get the index of dimension `y` through `get_index()`: ```python In [4]: arr.get_index('y') Out[4]: RangeIndex(start=0, stop=3, step=1, name='y') ``` - It says that: (see [link](https://docs.xarray.dev/en/stable/user-guide/data-structures.html#indexes:~:text=For%20convenience%20multi%2Dindex%20levels%20are%20directly%20accessible%20as%20%E2%80%9Cvirtual%E2%80%9D%20or%20%E2%80%9Cderived%E2%80%9D%20coordinates%20(marked%20by%20%2D%20when%20printing%20a%20dataset%20or%20data%20array)%3A)) > For convenience multi-index levels are directly accessible as “virtual” or “derived” coordinates (marked by - when printing a dataset or data array): > ```python > In [77]: mda[""band""] > Out[77]: > > array(['R', 'R', 'V', 'V'], dtype=object) > Coordinates: > * spec (spec) object MultiIndex > * band (spec) object 'R' 'R' 'V' 'V' > * wn (spec) float64 0.1 0.2 0.7 0.9 > > In [78]: mda.wn > Out[78]: > > array([0.1, 0.2, 0.7, 0.9]) > Coordinates: > * spec (spec) object MultiIndex > * band (spec) object 'R' 'R' 'V' 'V' > * wn (spec) float64 0.1 0.2 0.7 0.9 > ``` As you can see, even in the given example code offered by the offical, all the ""virtual"" coordinates are marked as `*` instead of `-`, which is a little bit confusing when handling multi-index coordinates in my experience. May I have missed something? Thanks in advance for the reply. ### What did you expect to happen? _No response_ ### Minimal Complete Verifiable Example _No response_ ### MVCE confirmation - [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [ ] Complete example — the example is self-contained, including all data and the text of any traceback. - [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [ ] New issue — a search of GitHub Issues suggests this is not a duplicate. ### Relevant log output _No response_ ### Anything else we need to know? _No response_ ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.10.102.1-microsoft-standard-WSL2 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: C.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.6.0 pandas: 1.4.3 numpy: 1.23.1 scipy: 1.3.3 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.1.2 cartopy: None seaborn: None numbagg: None fsspec: None cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 45.2.0 pip: 22.2.1 conda: None pytest: None IPython: 7.13.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6866/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue