Skip to content

Commit

Permalink
#26: correct cast
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Jul 26, 2022
1 parent 98e26b7 commit 7ad6194
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions basico/task_parameterestimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,18 @@ def _apply_nth_change(change, columns, df, dm, exp_name, independent, model, num
if change_set.size() > 0:
model.updateInitialValues(change_set)

def _get_value_from_bound(bound):
"""
:param bound: the bound for the fit item (a float value as string, or name of another reference)
:return: the value of the bound
:rtype: float
"""
try:
value = float(bound)
except ValueError:
value = basico.get_value(bound)
return value

def _update_fit_parameters_from(dm, solution, exp_name=''):
""" Utility function that updates the models fit parameters for the given solution
Expand All @@ -1174,8 +1186,8 @@ def _update_fit_parameters_from(dm, solution, exp_name=''):
for j in range(solution.shape[0]):
name = solution.iloc[j].name
value = solution.iloc[j].sol
lower= solution.iloc[j].lower
upper = solution.iloc[j].upper
lower= _get_value_from_bound(solution.iloc[j].lower)
upper = _get_value_from_bound(solution.iloc[j].upper)

cn = params.iloc[j].cn
if np.isnan(value):
Expand All @@ -1186,16 +1198,9 @@ def _update_fit_parameters_from(dm, solution, exp_name=''):

# ensure that values is within the constraint
if value < lower:
try:
value = str(lower)
except ValueError:
value = basico.get_value(lower)
value = lower
if value > upper:
try:
value = str(upper)
except ValueError:
value = basico.get_value(upper)

value = upper

obj = dm.getObject(COPASI.CCommonName(cn))

Expand Down

0 comments on commit 7ad6194

Please sign in to comment.