xarray
xarray copied to clipboard
Add invariant check for IndexVariable.name
@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
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!).
Here's a wilder idea:
@property.getter
def name(self) -> Hashable:
name, = self._dims
return name
@property.setter
def name(self):
# maybe warn for a while first
raise NotImplementedError