Skip to content

Commit

Permalink
TST: special: small improvements to Wright Omega tests
Browse files Browse the repository at this point in the history
- Use a smaller range for the systematic tests since the asymptotic
  regimes are simpler
- Use `assert_func_equal` for the real vs. complex implementation
  tests to get better error reporting
  • Loading branch information
person142 committed Sep 3, 2019
1 parent bd6325e commit 3ada772
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 5 additions & 2 deletions scipy/special/tests/test_mpmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1856,11 +1856,14 @@ def test_wrightomega_real(self):
def mpmath_wrightomega_real(x):
return mpmath.lambertw(mpmath.exp(x), mpmath.mpf('-0.5'))

# For x < -1000 the Wright Omega function is just 0 to double
# precision, and for x > 1e21 it is just x to double
# precision.
assert_mpmath_equal(
sc.wrightomega,
mpmath_wrightomega_real,
[Arg()],
rtol=1e-15,
[Arg(-1000, 1e21)],
rtol=5e-15,
atol=0,
nan_ok=False,
)
Expand Down
9 changes: 3 additions & 6 deletions scipy/special/tests/test_wrightomega.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from numpy.testing import assert_, assert_equal, assert_allclose

import scipy.special as sc
from scipy.special._testutils import assert_func_equal


def test_wrightomega_nan():
Expand Down Expand Up @@ -114,9 +115,5 @@ def test_wrightomega_exp_approximation_crossover():

def test_wrightomega_real_versus_complex():
x = np.linspace(-500, 500, 1001)
assert_allclose(
sc.wrightomega(x),
sc.wrightomega(x + 0j).real,
atol=0,
rtol=1e-14,
)
results = sc.wrightomega(x + 0j).real
assert_func_equal(sc.wrightomega, results, x, atol=0, rtol=1e-15)

0 comments on commit 3ada772

Please sign in to comment.