Skip to content

Commit

Permalink
fix CurveFit.fitParams in edge case w no curves (#58)
Browse files Browse the repository at this point in the history
Don't throw an uninterprtable error if ``CurveFits.fitParams`` called with no curves, instead just return empty data frame.
  • Loading branch information
jbloom authored Mar 26, 2024
1 parent bc76d62 commit c6b0c4b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <https://keepachangelog.com>`_.

2.0.1
-----

Fixed
+++++
- Don't throw an uninterprtable error if ``CurveFits.fitParams`` called with no curves, instead just return empty data frame.

2.0.0
-----

Added
+++++
- The curve fitting parameters (top, bottom, slope) can now be constrained to a range in addition to being completely free or fixed. This can help with fitting some curves more sensibly (see [this issue](https://github.com/jbloomlab/neutcurve/issues/53)). Specifically:
- ``fixtop`` and ``fixbottom`` parameters to ``HillCurve`` can be 2-tuples of bounds
- added ``fixslope`` parameter to ``HillCurve`` and ``CurveFits``
Expand Down
2 changes: 1 addition & 1 deletion neutcurve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

__author__ = "Jesse Bloom"
__email__ = "[email protected]"
__version__ = "2.0.0"
__version__ = "2.0.1"
__url__ = "https://github.com/jbloomlab/neutcurve"

from neutcurve.curvefits import CurveFits # noqa: F401
Expand Down
13 changes: 10 additions & 3 deletions neutcurve/curvefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,16 @@ def fitParams(
ic_cols += [prefix, f"{prefix}_bound", f"{prefix}_str"]
if ic50_error == "fit_stdev":
ic_cols.append("ic50_error")
self._fitparams[key] = pd.DataFrame(d)[
["serum", "virus", "replicate", "nreplicates"] + ic_cols + params
].assign(nreplicates=lambda x: (x["nreplicates"].astype("Int64")))
if len(d):
self._fitparams[key] = pd.DataFrame(d)[
["serum", "virus", "replicate", "nreplicates"] + ic_cols + params
].assign(nreplicates=lambda x: (x["nreplicates"].astype("Int64")))
else:
self._fitparams[key] = pd.DataFrame(
columns=["serum", "virus", "replicate", "nreplicates"]
+ ic_cols
+ params,
)

return self._fitparams[key]

Expand Down

0 comments on commit c6b0c4b

Please sign in to comment.