DataTree consolidation to use general AttrAccessMixin class (instead of TreeAttrAccessMixin) #9068
Labels
enhancement
needs triage
Issue that has not been reviewed by xarray team member
topic-DataTree
Related to the implementation of a DataTree class
What is your issue?
In #9011 code from datatree was merged into the main
xarray/core
subdirectory. This includes theTreeAttrAccessMixin
class, which is inherited byDataTree
. There is also a more generalAttrAccessMixin
class, which would be preferable to use instead.The reason that
AttrAccessMixin
is not just used forDataTree
is thatAttrAccessMixin.__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
(andTreeNode
andNamedNode
) do define__slots__
, but there are some attributes that are also declared dynamically (e.g.,DataTree.children
andDataTree.parent
, which are first defined inDataTree.__init__
). Because of these dynamic declarations,DataTree
has both__slots__
and__dict__
and therefore fails the check inAttrAccessMixin.__init_subcass__
.This issue aims to update
DataTree
(and potentiallyNamedNode
andTreeNode
, if needed), such thatDataTree
can pass the check inAttrAccessMixin.__init_subclass__
and the additionalTreeAttrAccessMixin
class can be removed.The text was updated successfully, but these errors were encountered: