Skip to content

Commit

Permalink
Fix SBML import for event-assigned parameters with non-float initial …
Browse files Browse the repository at this point in the history
…assignments (#2156)

Currently it is incorrectly assumed that the initial value of an event-assigned parameter
is (convertible to) a float. Therefore, SBML import fails if the initial assignment
contains a symbolic expression that can't be floatified.

Fixes #2149.
  • Loading branch information
dweindl authored Aug 16, 2023
1 parent 3cd3494 commit fa69dd3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ def _process_parameters(
for par in settings["var"]:
self.symbols[partype][_get_identifier_symbol(par)] = {
"name": par.getName() if par.isSetName() else par.getId(),
"value": par.getValue(),
"value": sp.Float(par.getValue()),
}

# Parameters that need to be turned into expressions
Expand Down Expand Up @@ -1382,13 +1382,13 @@ def _convert_event_assignment_parameter_targets_to_species(self):
ia_init = self._get_element_initial_assignment(par.getId())
parameter_def = {
"name": par.getName() if par.isSetName() else par.getId(),
"value": par.getValue() if ia_init is None else ia_init,
"value": sp.Float(par.getValue()) if ia_init is None else ia_init,
}
# Fixed parameters are added as species such that they can be
# targets of events.
self.symbols[SymbolId.SPECIES][parameter_target] = {
"name": parameter_def["name"],
"init": sp.Float(parameter_def["value"]),
"init": parameter_def["value"],
# 'compartment': None, # can ignore for amounts
"constant": False,
"amount": True,
Expand Down

0 comments on commit fa69dd3

Please sign in to comment.