-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typo about "len(arr.dims) <= len(arr.coords) in general" #7929
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
Thanks for the issue, always happy to improve the documentation. However, I don't really see how this implies that you cannot have more coordinates as dimensions. It is written that a coordinate labels a dimension or set of dimensions, so clearly you can have multiple coordinates per dimension. If you consider dimension-coordinates only, your example is correct. |
@ionsme can you suggest an improvement to the text please? It really helps when someone who's not a maintainer edits these things. |
@dcherian Ok, I'll think about a good wording a bit later and do that. |
@headtr1ck I agree that you can have multiple coordinates per dimension. However, the documentation explicitly says that you can't have it the other way around. I also agree that "if you consider dimension-coordinates only" is correct. In that case, the code given in the documentation should be changed to |
Oh wow, I completely missed the part where it says:
This is simply wrong, you are right. I don't think there is a direct way to retrieve dimension coordinates only. Maybe we should retire the concept of dimension coordinate and purely talk about indexes. At the end it is just a 1D index with the same name as the dimension. I think there are still special use cases for them, like automatic tics in plotting. |
Would it be possible to just make all coordinates dimension coordinates? At least, from the user interface point of view.By demoted I mean that you can't use it for things like selection, unless you use the workaround Also In terms of the graphing you mentioned, could just have the user select which coordinates to plot. Under the hood,I was thinking maybe there was some reason for this demoting. Naively though, I feel it should be possible to keep all coordinates as dimension coordinates. Maybe not the most efficient, but just to say it's possible, one could implement it as follows: |
It's not really possible because dimension coordinates have to be 1D, whereas coordinates in general can have any shape. Also, there are still some special usecases for them, i.e. automatic axis naming in plots, which only works if you have a 1D coordinate and a 1-to-1 relation between coordinate and dimension, aka. a dimension-coordinate. Indexing (so using |
@ionsme since a few releases it is possible to set a pandas index for non-dimension 1-d coordinates for using it with ds2 = ds.set_xindex("MyNonDimCoord")
ds2.sel(MyNonDimCoord="something") It is just not properly documented yet. I really need to finish #6975. |
Yes it seems like #6975 should close this issue. |
@benbovy Is there a reason that isn't done by default? So that the user never has to care about whether something is also an index? |
If we do that by default this would likely introduce breaking changes as the non-dimension 1-d coordinates would also become automatically aligned by default. Another reason is that building a (pandas) index is not free, although quite cheap most of the time. Some people asked the opposite, i.e., if it is possible in Xarray to not build any index by default (or choose another, non-pandas default index type) and/or deactivate automatic alignment. I guess we could expose some global options to control what should be the default behavior? Users seem to actually care about (the absence of) indexes, which is why they have been promoted as 1st-class citizens in the Xarray data model. |
Can we close this now? |
What happened?
Its on the website https://docs.xarray.dev/en/stable/user-guide/terminology.html, but isn't true in general.
What did you expect to happen?
the following code should return true, if the website is correct.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment
The text was updated successfully, but these errors were encountered: