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

DataTree consolidation to use general AttrAccessMixin class (instead of TreeAttrAccessMixin) #9068

Open
owenlittlejohns opened this issue Jun 4, 2024 · 0 comments
Labels
enhancement needs triage Issue that has not been reviewed by xarray team member topic-DataTree Related to the implementation of a DataTree class

Comments

@owenlittlejohns
Copy link
Contributor

What is your issue?

In #9011 code from datatree was merged into the main xarray/core subdirectory. This includes the TreeAttrAccessMixin class, which is inherited by DataTree. There is also a more general AttrAccessMixin class, which would be preferable to use instead.

The reason that AttrAccessMixin is not just used for DataTree is that AttrAccessMixin.__init_subclass__ has a check to see if there is a __dict__ attribute on the class. If there is, an error is thrown, saying that __slots__ should be used instead. DataTree (and TreeNode and NamedNode) do define __slots__, but there are some attributes that are also declared dynamically (e.g., DataTree.children and DataTree.parent, which are first defined in DataTree.__init__). Because of these dynamic declarations, DataTree has both __slots__ and __dict__ and therefore fails the check in AttrAccessMixin.__init_subcass__.

This issue aims to update DataTree (and potentially NamedNode and TreeNode, if needed), such that DataTree can pass the check in AttrAccessMixin.__init_subclass__ and the additional TreeAttrAccessMixin class can be removed.

@owenlittlejohns owenlittlejohns added needs triage Issue that has not been reviewed by xarray team member topic-DataTree Related to the implementation of a DataTree class enhancement labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs triage Issue that has not been reviewed by xarray team member topic-DataTree Related to the implementation of a DataTree class
Projects
Development

No branches or pull requests

1 participant