Skip to content

Adding support for CS output derivatives - #416

Open
PeterMeisrimelModelon wants to merge 1 commit into
masterfrom
dev-pm-481
Open

Adding support for CS output derivatives#416
PeterMeisrimelModelon wants to merge 1 commit into
masterfrom
dev-pm-481

Conversation

@PeterMeisrimelModelon

@PeterMeisrimelModelon PeterMeisrimelModelon commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

There are no real tests, since none of the reference FMUs actually support this.

@efredriksson-modelon efredriksson-modelon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good 🍎, some suggestions for making the implementation easier to read.

Comment thread src/pyfmi/fmi3.pyx
value_refs = np.array([0], dtype=np.uint32, ndmin=1).ravel()
orders = np.array([order], dtype=np.int32)
value_refs[0] = self.get_variable_valueref(variables)
elif isinstance(variables, list) and np.prod([int(isinstance(v, str)) for v in variables]): #prod equals 0 or 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we not just use all(isinstance(v, str)) for v in variables) here?

Comment thread src/pyfmi/fmi3.pyx
Comment on lines +4001 to +4004
if isinstance(variables, str):
nref = 1
value_refs = np.array([0], dtype=np.uint32, ndmin=1).ravel()
orders = np.array([order], dtype=np.int32)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To have less repetition we can use:

if isinstance(variables, str):
  variables = [variables]

to have this case transform to the general

Comment thread src/pyfmi/fmi3.pyx
Comment on lines +4013 to +4014
else:
raise FMUException("The variables must either be a string or a list of strings")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider having the error check first for an early return to have less cognitive load/indentation when reading the actual implementation.

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