Skip to content

Commit

Permalink
Fix #101, bugfix parameter fitting
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskoenig committed Mar 21, 2021
1 parent 35843f6 commit b3635b3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions release-notes/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- breaking changes in units handling
- bugfix plotting `dimensionless` units in labels
- remove deprecated `distrib` and `sampling` functionality.
- fixed typo in sensitivity

**parameter fitting**
- refactoring parameter fitting
Expand All @@ -18,3 +19,4 @@
- ‘arctan’ : rho(z) = arctan(z). Limits a maximum loss on a single residual, has properties similar to ‘cauchy’.
- figures closing in reports (#88)
- improved parameter fitting plots and results (#32)
- bugfix all NaN errors (#101)
11 changes: 11 additions & 0 deletions src/sbmlsim/fit/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def initialize(
# Changes to baseline, which is the first point
y_ref = y_ref - y_ref[0]

# --- errors on data ---
# Use errors for weighting (tries SD and falls back on SE)
y_ref_err = None
if data_ref.y_sd is not None:
Expand All @@ -356,15 +357,25 @@ def initialize(
y_ref_err_type = "SE"
else:
y_ref_err_type = None
# handle special case of all NaN
if np.all(np.isnan(y_ref_err)):
y_ref_err = None
y_ref_err_type = None

# handle missing data (0.0 and NaN)
if y_ref_err is not None:
# remove 0.0 from y-error
y_ref_err[(y_ref_err == 0.0)] = np.NAN
if np.all(np.isnan(y_ref_err)):
# handle special case of all NaN errors
logger.warning(
f"Errors are all NaN '{sid}.{mapping_id}' y data: "
f"'{y_ref_err}'"
)
y_ref_err = None
y_ref_err_type = None
else:
# FIXME: this must be based on coefficient of variation
# some NaNs could exist (err is maximal error of all points)
y_ref_err[np.isnan(y_ref_err)] = np.nanmax(y_ref_err)

Expand Down
2 changes: 1 addition & 1 deletion src/sbmlsim/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def default(self, o):

if hasattr(o, "to_dict"):
# custom serializer
print(type(o))
# print(type(o))
if isinstance(o, type):
print(o.__name__)
return o.to_dict()
Expand Down

0 comments on commit b3635b3

Please sign in to comment.