-
Notifications
You must be signed in to change notification settings - Fork 30
Handle reserved symbol names during code generation #2853
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
base: main
Are you sure you want to change the base?
Handle reserved symbol names during code generation #2853
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2853 +/- ##
==========================================
- Coverage 80.38% 80.27% -0.11%
==========================================
Files 329 329
Lines 22410 22413 +3
Branches 1514 1514
==========================================
- Hits 18014 17993 -21
- Misses 4385 4409 +24
Partials 11 11
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
|
|
||
| def _print_Symbol(self, expr: sp.Symbol) -> str: | ||
| name = super()._print_Symbol(expr) | ||
| if name in RESERVED_SYMBOLS and name != "t": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if a model has a parameter t that is not time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be happy to handle reserved symbols only during code generation, but I don't think this will work well in general. The problem is that we don't know anymore whether the given symbol is a user-defined symbol or an amici-internal symbol. There are quite a number of (currently unhandled) names that will cause problems, that we can't handle here (d{}dt, xdot{}, stau{}, any C++ keywords and typenames, any parameter names from amici's model functions, ...).
I think the most and only sustainable solution would be some string-based indexing that is evaluated at compile-time that avoids any collisions (see also #2226).



Summary
ModelQuantitysemantic-results-jaxdirectory for JAX SBML suite resultsTesting
pre-commit run --files python/sdist/amici/jax/ode_export.pypytest python/tests/test_sbml_import.py::test_import_same_model_name -vv -spytest python/tests/test_events.py::test_handling_of_fixed_time_point_event_triggers -qpytest tests/benchmark_models/test_petab_benchmark.py -k Boehm_JProteomeRes2014 -qpytest tests/benchmark_models/test_petab_benchmark_jax.py -k Boehm_JProteomeRes2014 -qpytest tests/sbml/testSBMLSuiteJax.py::test_sbml_testsuite_case_jax[00525] -qfixes #2461
https://chatgpt.com/codex/tasks/task_b_685d2802e714832b968ced9c529d9411