Skip to content

Inconsistent getter behavior when requested value does not exist #260

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

Open
ondras12345 opened this issue Apr 19, 2025 · 1 comment
Open
Assignees

Comments

@ondras12345
Copy link
Contributor

Example:

In [1]: import OMPython

In [2]: mod = OMPython.ModelicaSystem("/usr/share/doc/omc/testmodels/BouncingBall.mo", "BouncingBall", raiseerrors=True)

In [3]: mod.getOutputs("ThisOutputDoesNotExist")
Out[3]: ['NotExist']

In [4]: mod.simulate()

In [5]: mod.getOutputs("ThisOutputDoesNotExist")
Out[5]: ('ThisOutputDoesNotExist', ' is not Output')

In my opinion, it would be best to raise an exception (maybe KeyError?) in cases like this instead of returning invalid values. However, that would be an incompatible API change.

I'm currently trying to improve the docstrings for methods in ModelicaSystem. Should I document these weird quirks?

@syntron
Copy link
Contributor

syntron commented May 3, 2025

I'm currently trying to improve the docstrings for methods in ModelicaSystem. Should I document these weird quirks?

@ondras12345 I'm all for an exception - possible use raise ModelicaSystemException? I think it is important to tell the user as soon as possible if some function cannot work / will result in invalid data => fail early, fail hard ... - see also https://stackoverflow.com/questions/2807241/what-does-the-expression-fail-early-mean-and-when-would-you-want-to-do-so

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

3 participants