Skip to content

Commit

Permalink
ModelFactory models can now be initialized with names too
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Feb 2, 2022
1 parent 6f18f66 commit 85a709c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyenzyme/enzymeml/models/kineticmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,19 @@ def __call__(self, **variables) -> KineticModel:
for stock_variable in self.variables:

try:
identifier: str = variables[stock_variable]
identifier = variables[stock_variable]

if isinstance(identifier, list):
# Allow multiple species
identifier = [repr(name) for name in identifier]
identifier = f"({' * '.join(identifier)})"
else:
identifier = repr(identifier)

model.equation = model.equation.replace(
stock_variable, identifier
)

except KeyError:
raise KeyError(
f"Variable {stock_variable} has not been given. Please make sure to cover all variables: [{repr(self.variables)}]"
Expand Down

0 comments on commit 85a709c

Please sign in to comment.