Skip to content

Commit

Permalink
Catch overflow condition in IC50 calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
alubbock committed Jan 24, 2019
1 parent fe46e90 commit a3020b4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions thunor/curve_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from abc import abstractmethod
import pandas as pd
from decimal import Decimal
import warnings

PARAM_EQUAL_ATOL = 1e-16
PARAM_EQUAL_RTOL = 1e-12
Expand Down Expand Up @@ -217,10 +218,15 @@ def ic(self, ic_num=50):

ic_frac = ic_num / 100.0

icN = self.ec50 * (ic_frac / (1 - ic_frac - (emax / e0))) ** (
1 / self.hill_slope)
with warnings.filterwarnings(
'ignore',
'overflow encountered in double_scalars',
category=RuntimeWarning):
icN = self.ec50 * (ic_frac / (1 - ic_frac - (emax / e0))) ** (
1 / self.hill_slope)

if np.isnan(icN):
# Filtered overflow will lead to -inf, which we deal with here
if np.isnan(icN) or np.isinf(icN):
icN = None

return icN
Expand Down

0 comments on commit a3020b4

Please sign in to comment.