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

Update port.access_labels #1032

Merged
merged 5 commits into from
May 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions mbuild/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def access_labels(self):
list of str
Strings that can be used to access this Port relative to self.root
"""
access_labels = []
access_labels = set()
for referrer in self.referrers:
referrer_labels = [
key for key, val in self.root.labels.items() if val == referrer
Expand All @@ -171,9 +171,13 @@ def access_labels(self):
]
if referrer is self.root:
for label in port_labels:
access_labels.append("['{}']".format(label))
access_labels.add("['{}']".format(label))
for label in itertools.product(referrer_labels, port_labels):
access_labels.append("['{}']".format("']['".join(label)))
access_labels.add("['{}']".format("']['".join(label)))

for key, val in self.root.labels.items():
if self is val:
access_labels.add(f"['{key}']")

return access_labels

Expand Down