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

PseudoPotentialFamily: override remove_nodes and clear #29

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Dec 7, 2020

Fixes #27

These methods need to be overridden, such that after they have called
the implementation of the Group base class, the internal _pseudos
class attribute can be updated accordingly. For clear this is easy as
it is simply set to None, but for remove_nodes special care needs to
be taken. It needs to account for the fact that a single node or an
iterable of nodes can be passed as an argument, and that the base class
implementation will not raise if any of the nodes is not actually
contained in the group. So instead of doing the straight forward thing
of removing the nodes from _pseudos based on the elements, we remove
them based on the pk, which guarantees we are removing the correct nodes.

These methods need to be overridden, such that after they have called
the implementation of the `Group` base class, the internal `_pseudos`
class attribute can be updated accordingly. For `clear` this is easy as
it is simply set to `None`, but for `remove_nodes` special care needs to
be taken. It needs to account for the fact that a single node or an
iterable of nodes can be passed as an argument, and that the base class
implementation will not raise if any of the nodes is not actually
contained in the group. So instead of doing the straight forward thing
of removing the nodes from `_pseudos` based on the elements, we remove
them based on the pk, which guarantees we are removing the correct nodes.
@sphuber sphuber merged commit e2dfb82 into master Dec 7, 2020
@sphuber sphuber deleted the feature/027/family-remove-nodes-clear branch December 7, 2020 11:45
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.

PseudoPotentialFamily: override remove_nodes and clear
1 participant