Skip to content

Conversation

@ondras12345
Copy link
Contributor

I think it is a shame to get the x0 and u0 values from OpenModelica and throw them away without returning them to the user. Thus, I have changed ModelicaSystem.linearize() to return a dataclass with all the available information.

To avoid breaking code that relies on the old return value, I have made it possible to unpack the dataclass into (A,B,C,D), as well as to use indexes 0-3 to access the matrices.
However, there are still cases where the new return value behaves differently, e.g. if someone passed the old result straight to json.dumps().

An alternative approach would be to preserve the old return value and add a new function:

def linearize_new([...]) -> LinearizationResult:
    ...

def linearize(*args, **kwargs):
    r = linearize_new(*args, **kwargs)
    return list(r)

It is up to you to decide whether changing the return value like this is acceptable. If you decide to go with the alternative approach outlined above, I'll rework this pull request.

@ondras12345 ondras12345 force-pushed the linearize-dataclass branch from 59d8ec2 to faee5cf Compare April 25, 2025 14:20
Copy link
Collaborator

@arun3688 arun3688 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks good

@arun3688 arun3688 merged commit 0b63a2b into OpenModelica:master Apr 25, 2025
5 checks passed
@syntron syntron mentioned this pull request Sep 28, 2025
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.

2 participants