Skip to content

Commit 6ebf6a3

Browse files
authored
Fix AlgebraicRule processing (#2744)
Fix the check for whether a species that occurs in an AlgebraicRule participates in any reaction. If that species occurs in multiple AlgebraicRule, it will have been removed from `self.symbols[SymbolId.SPECIES]` by the time the second rule is processed.
1 parent 8680cf5 commit 6ebf6a3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

python/sdist/amici/sbml_import.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,11 +1533,17 @@ def _process_rule_algebraic(self, rule: libsbml.AlgebraicRule):
15331533
and sbml_var.isSetBoundaryCondition()
15341534
and sbml_var.getBoundaryCondition()
15351535
)
1536-
is_involved_in_reaction = is_species and not smart_is_zero_matrix(
1537-
self.stoichiometric_matrix[
1538-
list(self.symbols[SymbolId.SPECIES].keys()).index(symbol),
1539-
:,
1540-
]
1536+
is_involved_in_reaction = (
1537+
is_species
1538+
and symbol in self.symbols[SymbolId.SPECIES]
1539+
and not smart_is_zero_matrix(
1540+
self.stoichiometric_matrix[
1541+
list(self.symbols[SymbolId.SPECIES].keys()).index(
1542+
symbol
1543+
),
1544+
:,
1545+
]
1546+
)
15411547
)
15421548
if (
15431549
is_species

0 commit comments

Comments
 (0)