Skip to content

Inconsistent getter behavior when requested value does not exist #260

Closed

Description

@ondras12345

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?

Activity

  1. syntron commented on May 3, 2025

    @syntron
    Contributor

    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

  2. added this to the milestone on Jun 11, 2025
  3. modified the milestones: , 4.0.0 on Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions