You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent getter behavior when requested value does not exist #260
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?
Activity
syntron commentedon May 3, 2025
@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