diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index a54f8ebe0b..d207ffbf9a 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -556,9 +556,14 @@ def _build_ode_model( dxdt = smart_multiply( self.stoichiometric_matrix, MutableDenseMatrix(fluxes) ) - # there may be an additional 0-entry at the end of the - # stoichiometric matrix / flux vector - assert dxdt.shape[0] - len(self.symbols[SymbolId.SPECIES]) in (0, 1) + # dxdt has algebraic states at the end + assert dxdt.shape[0] - len(self.symbols[SymbolId.SPECIES]) == len( + self.symbols.get(SymbolId.ALGEBRAIC_STATE, []) + ), ( + self.symbols[SymbolId.SPECIES], + dxdt, + self.symbols[SymbolId.SPECIES], + ) # correct time derivatives for compartment changes for ix, ((species_id, species), formula) in enumerate(