Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create-jupyter-notebook creates illegal Python code for multiline description strings if HTML entity for newline is used #703

Closed
dietmarw opened this issue Oct 25, 2024 · 1 comment · Fixed by #710
Labels

Comments

@dietmarw
Copy link

I noticed that when I run fmpy create-jupyter-notebook test.fmu where the test.fmu was generated from the following Modelica code:

model test
 parameter Real a = 1 "foo,
 bar,
 baz";
end test;

I get a jupyter notbook with this Python code cell:

import fmpy
from fmpy import *


filename = 'test.fmu'

start_values = {
    # variable    start   unit      description
    'a':            1.0,          # foo,
 bar,
 baz
}

output = [
    'a',  # foo,
 bar,
 baz
]

result = simulate_fmu(filename, start_values=start_values, output=output, stop_time=1.0)

plot_result(result)

Looking into it, I saw that OpenModelica is using the HTML entity for the newline char. I.e., the modeldescription.xml from the OpenModelica exported fmu contains:

description="foo,
 bar,
 baz"

whilst the one from Dymola is

description="foo,\n bar,\n baz"

I'm not sure if this is now something that OpenModelica does against some standard or if the create-jupyter-notebook simply fails to catch this.

@dietmarw
Copy link
Author

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants