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

merge nodes with duplicated properties #45

Open
vgrcs opened this issue Jan 16, 2023 · 0 comments
Open

merge nodes with duplicated properties #45

vgrcs opened this issue Jan 16, 2023 · 0 comments

Comments

@vgrcs
Copy link

vgrcs commented Jan 16, 2023

Hi,

Does it make sense to implement the "merge" method in the Node class based on the union of properties instead of concatenation of lists? This is the implementation that suits my problem:

def merge(self, other: 'Node'):
"""Merge the contents of a node into this node.
Used by Node.merge_trees()
"""
if not self.label and other.label:
self.label = other.label
#self.properties += other.properties
self.properties = [value for value in self.properties if value not in other.properties]
#self.directives += other.directives
self.directives = [value for value in self.directives if value not in other.directives]
self.children += other.children

Best regards,
Vitor

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