diff --git a/release-notes/next-release.md b/release-notes/next-release.md index 96f3727a..6f7831d5 100644 --- a/release-notes/next-release.md +++ b/release-notes/next-release.md @@ -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 @@ -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) diff --git a/src/sbmlsim/fit/optimization.py b/src/sbmlsim/fit/optimization.py index 354efe54..4c0076bf 100644 --- a/src/sbmlsim/fit/optimization.py +++ b/src/sbmlsim/fit/optimization.py @@ -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: @@ -356,6 +357,10 @@ 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: @@ -363,8 +368,14 @@ def initialize( 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) diff --git a/src/sbmlsim/serialization.py b/src/sbmlsim/serialization.py index c85c9d18..9cde069c 100644 --- a/src/sbmlsim/serialization.py +++ b/src/sbmlsim/serialization.py @@ -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()