Skip to content
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

Add invariant check for IndexVariable.name #8906

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Apr 4, 2024

@benbovy this seems to be the root cause of #8646, the variable name in Dataset._variables does not match IndexVariable.name.

A good number of tests seem to fail though, so not sure if this is a good chck.

  • Closes #xxxx
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

@dcherian dcherian requested a review from benbovy April 4, 2024 02:13
@dcherian dcherian changed the title Add invariant check for #8646 Add invariant check for IndexVariable.name Apr 4, 2024
@benbovy
Copy link
Member

benbovy commented Apr 4, 2024

Thanks @dcherian, that's a good check to have I think. Most (if not all?) errors seem to be multi-index level variables that wrongly have their dimension name set as IndexVariable .name. I haven't looked into it yet but there might probably be an easy fix (hopefully!).

@@ -2590,12 +2590,14 @@ class IndexVariable(Variable):
unless another name is given.
"""

__slots__ = ()
__slots__ = ("_name",)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the name property instead or is that much much harder?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better indeed but this is likely more work (not sure how much, though).

IndexVariable still needs a deeper refactor (#8124), or even be eventually dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the .name property used?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a quick check: internally only in a few places (conventions / multiindex check, dataarray creation, maybe groupby?) actually.

Externally I have no idea (IndexVariable is public API in theory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants