Skip to content

Commit

Permalink
don't use .ae method in library code
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-johansson committed Jan 10, 2023
1 parent 1258e33 commit 9d7884b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mpmath/calculus/extrapolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ def init_levin(m):
error = lerror
best = est
if TRY_EULER_MACLAURIN:
if ctx.mpc(ctx.sign(partial[-1]) / ctx.sign(partial[-2])).ae(-1):
if ctx.almosteq(ctx.mpc(ctx.sign(partial[-1]) / ctx.sign(partial[-2])), -1):
if verbose:
print ("NOT using Euler-Maclaurin: the series appears"
" to be alternating, so numerical\n quadrature"
Expand Down
2 changes: 2 additions & 0 deletions mpmath/tests/test_summation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def test_nsum():
assert nsum(lambda k: 1/k**2, [1, inf]).ae(pi**2 / 6)
assert nsum(lambda k: 2**k/fac(k), [0, inf]).ae(exp(2))
assert nsum(lambda k: 1/k**2, [4, inf], method='e').ae(0.2838229557371153)
assert abs(fp.nsum(lambda k: 1/k**4, [1, fp.inf]) - 1.082323233711138) < 1e-5
assert abs(fp.nsum(lambda k: 1/k**4, [1, fp.inf], method='e') - 1.082323233711138) < 1e-4

def test_nprod():
mp.dps = 15
Expand Down

0 comments on commit 9d7884b

Please sign in to comment.