opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
800 stars 323 forks source link

Throw if passed in name or index of marker is invalid #3970

Closed aymanhab closed 1 day ago

aymanhab commented 4 days ago

Fixes issue #3951

Brief summary of changes

This was mainly an issue with trying to call methods on markers that are not in the intersection of model markers and those in the trc file. Code innocently assumed names passed in to be valid. Now throw exceptions and test case beefed up accordingly.

Testing I've completed

Looking for feedback on...

CHANGELOG.md (choose one)


This change is Reviewable

carmichaelong commented 3 days ago

@aymanhab thanks for looking into this. The code looks good, but I think I'm realizing there are some higher level questions to sort first (we can chat about this in person too if that's quicker too, but wanted to put my thoughts down here before I forget):

aymanhab commented 3 days ago

@carmichaelong I agree with your assessment overall. Just keep in mind that the solver is a low level class designed to be efficient use-at-your-own-risk type, while the tool is more the user facing abstraction. I'd move the methods that take an index to be private as indexing is into an internal container, and require clients to use names exclusively along with the method to get the name of marker/orientation for an index. Please let me know if that would be sufficient on balance.

aymanhab commented 2 days ago

Done @carmichaelong thanks for the quick turnaround and review.

carmichaelong commented 2 days ago

Thanks @aymanhab. Sorry one more other thing I should have mentioned: just adding the same tests that make sure all the updated methods properly throw would be helpful.

aymanhab commented 2 days ago

ok, done @carmichaelong will wait for ci to finish, let me know if ready to go then. Thank you

aymanhab commented 1 day ago

@carmichaelong ready to go?

aymanhab commented 1 day ago

Thanks @carmichaelong 👍