Skip to content

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
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.

3 participants