Skip to content

ModelicaModel.getParameters returns values as string instead of float #244

Closed as not planned

Description

@ondras12345

Description

The documentation seems to indicate that the values of Real parameters should be returned as float:

>>> mod.getParameters()  // method-1
{'c': 0.9, 'radius': 0.1}

However, strings are returned in practice - something like this:

{'c': '0.9', 'radius': '0.1'}

Steps to Reproduce

I have added a test for this (currently failing) to my fork:
https://github.com/ondras12345/OMPython/blob/53fc10ded9a89d33238c529352bc01f989a80e80/tests/test_ModelicaSystem.py#L33-L46

Expected Behavior

Library behavior should match documentation.

Version and OS

  • Python Version: 3.12.3
  • OMPython Version: 5904e4e
  • OpenModelica Version: 1.25.0
  • OS: Ubuntu 24.04.2 LTS

I might have a look at fixing this myself. However, I would someone to confirm whether changing the behavior to match the documentation would be acceptable. I guess it would technically break backwards compatibility.

Activity

  1. arun3688 commented on Apr 7, 2025

    @arun3688
    Collaborator

    @ondras12345 you are correct, it was a typos, But in general to keep the API consistent in OMjulia, OMPython and OMMatlab, we set the values as string and return the values as String, we do not perform any type checking, But however if you want to return with correct types, you can make a PR with your changes

  2. ondras12345 commented on Apr 7, 2025

    @ondras12345
    ContributorAuthor

    Keeping the API consistent seems like a good reason. I will change the test to match current behavior.

  3. added a commit that references this issue on Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions