Closed shawnyama closed 3 weeks ago
"time": {
"id": "t",
"units": {
"expression": "day unit",
"expression_mathml": "<ci>day unit</ci>"
}
This looks like the actual python stack trace:
ValueError: Error from parse_expr with transformed code: "day Symbol ('unit' )"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File [/opt/conda/lib/python3.11/site-packages/IPython/core/interactiveshell.py:3577](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/IPython/core/interactiveshell.py#line=3576) in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
Cell In[72], line 7
mmt = model_from_json(amr)
File [/opt/conda/lib/python3.11/site-packages/mira/sources/amr/__init__.py:67](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/mira/sources/amr/__init__.py#line=66) in model_from_json
return petrinet.template_model_from_amr_json(model_json)
File [/opt/conda/lib/python3.11/site-packages/mira/sources/amr/petrinet.py:153](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/mira/sources/amr/petrinet.py#line=152) in template_model_from_amr_json
time_units_expr = get_sympy(time_units, UNIT_SYMBOLS)
File [/opt/conda/lib/python3.11/site-packages/mira/sources/util.py:218](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/mira/sources/util.py#line=217) in get_sympy
expr = safe_parse_expr(expr_data["expression"], local_dict=local_dict)
File [/opt/conda/lib/python3.11/site-packages/mira/metamodel/utils.py:34](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/mira/metamodel/utils.py#line=33) in safe_parse_expr
return sympy.parse_expr(get_parseable_expression(s),
File [/opt/conda/lib/python3.11/site-packages/sympy/parsing/sympy_parser.py:1087](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/sympy/parsing/sympy_parser.py#line=1086) in parse_expr
raise e from ValueError(f"Error from parse_expr with transformed code: {code!r}")
File [/opt/conda/lib/python3.11/site-packages/sympy/parsing/sympy_parser.py:1078](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/sympy/parsing/sympy_parser.py#line=1077) in parse_expr
rv = eval_expr(code, local_dict, global_dict)
File [/opt/conda/lib/python3.11/site-packages/sympy/parsing/sympy_parser.py:906](http://10.64.18.171:8888/opt/conda/lib/python3.11/site-packages/sympy/parsing/sympy_parser.py#line=905) in eval_expr
expr = eval(
File <string>:1
day Symbol ('unit' )
^
SyntaxError: invalid syntax
DC edit July 18
Looks like this is because sympy is trying to parse
blah blah
as an expression and doesn't like the space-character. We should take a look at how prevalent we need to guard against these cases. It may be worthwhile to add an option to tera-input component to reject specific characters, rather than doing the string wrangling after-the-fact.Shawn Original
Describe the bug Rendering the model parts requires the
mmt
so we know the base variables in the case of stratified states/parameters/transitions. Once a unit expression is given a space theamr_to_mmt
conversion doesn't work causing the editing UI to not render. In order to avoid this for now I prevent spaces from being entered in the unit fields.To Reproduce
https://github.com/user-attachments/assets/7fe8cf95-fc92-40bd-96ad-c4b0579615c9
Error: