summaryrefslogtreecommitdiff
path: root/numpy/random/tests/test_random.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-10-06 09:03:32 -0600
committerCharles Harris <charlesr.harris@gmail.com>2017-10-06 09:03:32 -0600
commit45e00937723064f14752fc88c18e7146e62789a0 (patch)
tree4aaf30fb025486fc2804f30e9e48f5320dfece5e /numpy/random/tests/test_random.py
parente6932a8266ca2e1d1fdc7ec78e9254b6563b0e39 (diff)
downloadnumpy-45e00937723064f14752fc88c18e7146e62789a0.tar.gz
BUG: Check for NaN parameter in random.zipf.
Avoids infinite loop.
Diffstat (limited to 'numpy/random/tests/test_random.py')
-rw-r--r--numpy/random/tests/test_random.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index a530b9e13..e9c9bc492 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -1106,13 +1106,13 @@ class TestBroadcast(object):
assert_raises(ValueError, nonc_f, bad_dfnum, dfden, nonc * 3)
assert_raises(ValueError, nonc_f, dfnum, bad_dfden, nonc * 3)
assert_raises(ValueError, nonc_f, dfnum, dfden, bad_nonc * 3)
-
+
def test_noncentral_f_small_df(self):
self.setSeed()
desired = np.array([6.869638627492048, 0.785880199263955])
actual = np.random.noncentral_f(0.9, 0.9, 2, size=2)
assert_array_almost_equal(actual, desired, decimal=14)
-
+
def test_chisquare(self):
df = [1]
bad_df = [-1]
@@ -1434,6 +1434,10 @@ class TestBroadcast(object):
actual = zipf(a * 3)
assert_array_equal(actual, desired)
assert_raises(ValueError, zipf, bad_a * 3)
+ with np.errstate(invalid='ignore'):
+ assert_raises(ValueError, zipf, np.nan)
+ assert_raises(ValueError, zipf, [0, 0, np.nan])
+
def test_geometric(self):
p = [0.5]