-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix issue tuple as dimension #5477
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
Fix issue tuple as dimension #5477
Conversation
This looks good! The one corner case I'm not sure this handles is when there is actually a tuple dimension. If that's correct, could we add a test for that case, and maybe here check that it's a tuple and it's not in the dimensions?
Great, tbc we want that construction to pass — we're saying it's allowable to have tuples as dimension names (while not encouraging it!) Thanks @thomashirtz |
This was quite close @thomashirtz — let me know if you'd be up for finishing it off. Thanks |
I would like to continue to contribute to xarray, unfortunately I have many important matters theses days. I may contribute again from end of summer. If someone wants to tackle this issue until then, he can |
I think this should be also aligned with |
Good point... IIUC (and it's been a while since I thought through this properly), this would support allowing tuples as dimension names, but forcing them to be passed within an iterable to methods (e.g. |
I would say that a tuple is fine, it IS an iterable of hashable ;) |
Sorry, yes, I was unclear above! How should we handle dimensions which are themselves tuples? (i.e. a really unlikely corner-case, but one that IIRC inspired some of the discussion in #4821) My thought was to interpret a tuple as an iterable of dimensions. If we have a dimension name of a tuple, then that requires passing within an Iterable — i.e. the Does that make sense? V possible my writing and / or thinking is still not clear! |
Yes exactly, that would be the intended way of working with dimensions/variables that are iterablea themself, like tuples. |
I edited dataset in core to try to solve the issue 4821. Some tests are still currently missing, also I believe there is still one more issue related to using tuple as dim.
The code
xr.Dataset({"a": ([("a", "b")], [1])})
does not error yet.pre-commit run --all-files
whats-new.rst