Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
FFroehlich committed Jan 31, 2025
1 parent a88c056 commit c0c0cdf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2292,16 +2292,25 @@ def _make_initial(

sym_math, rateof_to_dummy = _rateof_to_dummy(sym_math)

# we can't rely on anything else being properly initialized at this point, so we need to
# compute all initial values from scratch, recursively
for var in sym_math.free_symbols:
element_id = str(var)
# already recursive since _get_element_initial_assignment calls _make_initial
ia = self._get_element_initial_assignment(str(var))
if ia is not None:
if (
ia := self._get_element_initial_assignment(element_id)
) is not None:
sym_math = sym_math.subs(var, ia)

Check warning on line 2303 in python/sdist/amici/sbml_import.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/sbml_import.py#L2303

Added line #L2303 was not covered by tests

elif (species := self.sbml.getSpecies(str(var))) is not None:
elif (species := self.sbml.getSpecies(element_id)) is not None:
# recursive!
init = self._make_initial(get_species_initial(species))
sym_math = sym_math.subs(var, init)

Check warning on line 2307 in python/sdist/amici/sbml_import.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/sbml_import.py#L2306-L2307

Added lines #L2306 - L2307 were not covered by tests
elif (
element := self.sbml.getElementBySId(element_id)
) and self.is_rate_rule_target(element):
# no need to recurse here, as value is numeric
init = sp.Float(element.getValue())
sym_math = sym_math.subs(var, init)

Check warning on line 2313 in python/sdist/amici/sbml_import.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/sbml_import.py#L2312-L2313

Added lines #L2312 - L2313 were not covered by tests

sym_math = smart_subs(sym_math, sbml_time_symbol, sp.Float(0))

Expand Down

0 comments on commit c0c0cdf

Please sign in to comment.