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

Remove dependency on anytree #7

Closed
TomNicholas opened this issue Aug 20, 2021 · 2 comments
Closed

Remove dependency on anytree #7

TomNicholas opened this issue Aug 20, 2021 · 2 comments
Milestone

Comments

@TomNicholas
Copy link
Collaborator

The code currently has a hard dependency on the anytree library, which it uses primarily to implement the actual .parent & .children structure of the TreeNode class, through inheritance from anytree.NodeMixin.

We don't need this dependency - anytree is not a big project, and we can simply reimplement the classes we need within this project instead. We should give due credit in the code because anytree has an Apache 2.0 license (plus Scout's honor).

Reimplementing anytree's functionality would also allow us to change various parts of it. For example we don't need support for python 2, we can standardize the error types (e.g. to return KeyError instead of e.g. anytree.ResolverError), and get rid of the mis-spelled .anchestors property. We shouldn't need to worry about breaking the code because the tree functionality is already covered by the unit tests in test_treenode.py.

@TomNicholas
Copy link
Collaborator Author

I think that for the __slots__ defined in DatasetArithmetic and other places in xarray to work then the whole chain of subclasses must define slots, but anytree.NodeMixin does not define it. Unless we can monkey-patch __slots__ onto anytree.NodeMixin then this would be another benefit of re-implementing NodeMixin ourselves.

@TomNicholas
Copy link
Collaborator Author

Closed by #76

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

No branches or pull requests

1 participant