Skip to content

Commit c68c1db

Browse files
committed
Fix too-lenient tolerance in convergence check
1 parent 424c2dc commit c68c1db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tsdate/hypergeo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
import numpy as np
3030
from numba.extending import get_cython_function_address
3131

32+
# TODO: these are reasonable defaults, but could
33+
# be made settable via a control dict
3234
_HYP2F1_TOL = np.sqrt(np.finfo(np.float64).eps)
33-
_HYP2F1_CHECK = np.sqrt(_HYP2F1_TOL)
3435
_HYP2F1_MAXTERM = int(1e6)
3536

3637
_PTR = ctypes.POINTER
@@ -115,7 +116,7 @@ def _is_valid_2f1(f1, f2, a, b, c, z):
115116
See Eq. 6 in https://doi.org/10.1016/j.cpc.2007.11.007
116117
"""
117118
if z == 0.0:
118-
return np.abs(f1 - a * b / c) < _HYP2F1_CHECK
119+
return np.abs(f1 - a * b / c) < _HYP2F1_TOL
119120
u = c - (a + b + 1) * z
120121
v = a * b
121122
w = z * (1 - z)
@@ -124,7 +125,7 @@ def _is_valid_2f1(f1, f2, a, b, c, z):
124125
numer = np.abs(u * f1 - v)
125126
else:
126127
numer = np.abs(f2 + u / w * f1 - v / w)
127-
return numer / denom < _HYP2F1_CHECK
128+
return numer / denom < _HYP2F1_TOL
128129

129130

130131
@numba.njit("UniTuple(float64, 7)(float64, float64, float64, float64)")

0 commit comments

Comments
 (0)