Skip to content

Commit

Permalink
- fix an issue where set_value would not correctly update initial_co…
Browse files Browse the repository at this point in the history
…ncentrations
  • Loading branch information
fbergmann committed Aug 4, 2022
1 parent a801941 commit 51981bd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions basico/model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4484,15 +4484,16 @@ def _set_value_from_reference(obj, new_value):
if parent is None:
return None
name = obj.getObjectName()
value = _set_named_value(parent, name, new_value)
value = _set_named_value(parent, name, new_value, obj)
return value

def _set_named_value(obj, name, new_value):
def _set_named_value(obj, name, new_value, ref):
""" Utility function that sets the value of the given copasi object
:param obj: a copasi object, that could be a compartment, species, parameter, reaction
:param name: the reference name to set
:param new_value: the new value for the element
:param ref: the reference object
:return:None
"""
is_metab = isinstance(obj, COPASI.CMetab)
Expand Down Expand Up @@ -4545,10 +4546,10 @@ def _set_named_value(obj, name, new_value):
if set_function is not None:
if p_name is not None:
set_function(p_name, new_value)
model.updateInitialValues(obj)
model.updateInitialValues(ref)
else:
set_function(new_value)
model.updateInitialValues(obj)
model.updateInitialValues(ref)

return

Expand Down

0 comments on commit 51981bd

Please sign in to comment.