Skip to content

Conversation

syntron
Copy link
Contributor

@syntron syntron commented Aug 15, 2025

improve input handling for set*() functions

  • use a Pythonic way for input:
    setParameters(a=123)

    param = {'a': 123}
    setParameters(**param)

Based on PR #314 with input from SengerM (see PR #326); this replaces PR #326

@syntron
Copy link
Contributor Author

syntron commented Aug 16, 2025

@adeas31 one thing I did not checked but which is quite important to confirm here: are there the same rules for variable names in Python and OpenModelica? I assume yes and then all is fine - if not this PR should not be applied!

syntron added a commit to syntron/OMPython that referenced this pull request Aug 16, 2025
@adeas31 adeas31 added this to the 4.0.0 milestone Aug 18, 2025
@syntron syntron force-pushed the ModelicaSystem_improve_set_functions branch from 171c0f5 to 41c9d31 Compare August 20, 2025 17:33
@adeas31
Copy link
Member

adeas31 commented Aug 21, 2025

@adeas31 one thing I did not checked but which is quite important to confirm here: are there the same rules for variable names in Python and OpenModelica? I assume yes and then all is fine - if not this PR should not be applied!

Which variables are you talking about? Did you mean Modelica and not OpenModelica?

@adeas31
Copy link
Member

adeas31 commented Aug 21, 2025

Also as I understand this supersedes PR #326.

@syntron
Copy link
Contributor Author

syntron commented Aug 21, 2025

Also as I understand this supersedes PR #326.

@adeas31 Yes, the interface uses the idea of @SengerM (PR #326). It adds this way of defining arguments not only to setParameters() but all set*() functions.

Which variables are you talking about? Did you mean Modelica and not OpenModelica?

Just to confirm: the definition of a valid variable in Modelica is eual to the definition in Python, i.e. must start with a letter (or underscore?) and can only contain leters, numbers and underscore.

The reason for this is that by using the code in this PR, the Modelica variables are used as Python variables. Thus, the rules should match in this direction.

@SengerM
Copy link

SengerM commented Aug 22, 2025

Which variables are you talking about? Did you mean Modelica and not OpenModelica?

The rules for identifiers in Python and the ones for Modelica.

The reason for this is that by using the code in this PR, the Modelica variables are used as Python variables. Thus, the rules should match in this direction.

Even if the naming rules are a bit different, you can overcome this issue if the current string interface is maintained for those specific cases.

@adeas31 adeas31 modified the milestones: 4.0.0, 4.1.0 Aug 22, 2025
@syntron syntron force-pushed the ModelicaSystem_improve_set_functions branch from 41c9d31 to 6102df1 Compare August 23, 2025 12:43
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