-
-
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
WIP: don't create indexes on multidimensional dimensions #2405
Conversation
xarray/core/formatting.py
Outdated
@@ -272,7 +272,8 @@ def summarize_datavar(name, var, col_width): | |||
|
|||
|
|||
def summarize_coord(name, var, col_width): | |||
is_index = name in var.dims | |||
from .variable import IndexVariable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried moving this import to the top of formatting.py
but, for reasons I can't understand, I got this error
from .variable import IndexVariable
E ImportError: cannot import name 'IndexVariable
Why does it work in the function but not at the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a circular import going on here, as .variable does import .common which does import .formatting Perhaps adding a self.is_index attribute to the Variable class could be a way to avoid this import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have a circular import here. We could potentially refactor to avoid but I think this is also an OK work-around.
Seeking suggestions about what else needs to be tested here. |
I turned up a few lines that probably need to be fixed, just by grepping for Lines 125 to 126 in 66a8f8d
xarray/xarray/core/coordinates.py Lines 111 to 116 in 66a8f8d
xarray/xarray/core/dataarray.py Line 502 in 66a8f8d
It looks like this change broke |
It would be good to add a tests for these variables in:
|
68f170c
to
40c8d36
Compare
Hello @rabernat! Thanks for updating the PR.
|
I had some spare time and started working on this again. I'm scared of how much internal refactoring it requires. For example, this function Lines 92 to 113 in 385b36c
just doesn't make sense any more if dimensions are not guaranteed to be one-dimensional. I've never touched this part of the code base before. I have no idea how many places there are that make such an assumption. |
I think this function mostly makes sense, but we would want to drop the stuff for scalar variables. Unfortunately I don't know a good way to fix this stuff short of auditing a lot of code manually -- this is a hazard of data model changes. On the plus side, I've also started to do some of this for the explicit index refactor. One thing that might turn up a few bugs is to try adding such a variable to the create_test_data() helper function which gets used in lots of places. |
whats-new.rst
for all changes andapi.rst
for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)This is just a start to the solution proposed in #2368. A surprisingly small number of tests broke in my local environment.