Browse files

BUG: special: nan safety in smirnovi & kolmogi

  • Loading branch information...
1 parent f7083b6 commit 2858f452b8083f1eca4499889e6b43942c2eda03 @pv pv committed May 11, 2012
Showing with 5 additions and 2 deletions.
  1. +2 −2 scipy/special/cephes/kolmogorov.c
  2. +3 −0 scipy/special/tests/test_basic.py
View
4 scipy/special/cephes/kolmogorov.c
@@ -117,7 +117,7 @@ smirnovi (n, p)
double e, t, dpde;
int iterations;
- if (p <= 0.0 || p > 1.0)
+ if (!(p > 0.0 && p <= 1.0))
{
mtherr ("smirnovi", DOMAIN);
return (NPY_NAN);
@@ -165,7 +165,7 @@ kolmogi (p)
double y, t, dpdy;
int iterations;
- if (p <= 0.0 || p > 1.0)
+ if (!(p > 0.0 && p <= 1.0))
{
mtherr ("kolmogi", DOMAIN);
return (NPY_NAN);
View
3 scipy/special/tests/test_basic.py
@@ -268,6 +268,7 @@ def test_kn(self):
def test_kolmogi(self):
assert_equal(cephes.kolmogi(1),0.0)
+ assert_(np.isnan(cephes.kolmogi(np.nan)))
def test_kolmogorov(self):
assert_equal(cephes.kolmogorov(0),1.0)
@@ -428,9 +429,11 @@ def test_sindg(self):
assert_equal(cephes.sindg(90),1.0)
def test_smirnov(self):
assert_equal(cephes.smirnov(1,.1),0.9)
+ assert_(np.isnan(cephes.smirnov(1,np.nan)))
def test_smirnovi(self):
assert_almost_equal(cephes.smirnov(1,cephes.smirnovi(1,0.4)),0.4)
assert_almost_equal(cephes.smirnov(1,cephes.smirnovi(1,0.6)),0.6)
+ assert_(np.isnan(cephes.smirnovi(1,np.nan)))
def test_spence(self):
assert_equal(cephes.spence(1),0.0)

0 comments on commit 2858f45

Please sign in to comment.