Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make getNodeForName method match entire name #42

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

austin-hoover
Copy link
Contributor

Currently getNodeForName(name) returns node if node.getName().find(name) == 0. This throws an error if there is another node with the same prefix. For example:

names = ["QH10", "QH10A", "QH10B"]
for name in names:
    print(name, name.find("QH10"))
QH10 0
QH10A 0
QH10B 0

Is this intended behavior?

@shishlo
Copy link
Contributor

shishlo commented Jan 12, 2025

I agree that
if node.getName().find(name) == 0:
should be replaced with
if node.getName() == name:

The same also should be done inside (line 140)
def getNodesForName(self, name):

The error for
def getNodeForName(self, name):
should tell that there are several AccNodes with the same name (it could happen in TEAPOT lattices), and user should be aware about that and should use "getNodesForName" method.

@azukov azukov merged commit 709a5cc into PyORBIT-Collaboration:main Jan 21, 2025
4 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants