summaryrefslogtreecommitdiff
path: root/numpy/random/tests/test_random.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-05-28 19:28:25 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-05-28 20:11:22 +0200
commit69e26e54edd3c83fae61e880a102d1b979e2d67d (patch)
tree6f61be263e2feefa177dc67f8148af7e71e1dee8 /numpy/random/tests/test_random.py
parentc24cc4e36a52d7892817d4f94b8e8ccaa38852b6 (diff)
downloadnumpy-69e26e54edd3c83fae61e880a102d1b979e2d67d.tar.gz
BUG: avoid infinite loop for small kappa in vonmises
rho results in 0. for kappa < 1.4e-8 whch leads to nans appearing and an infinite loop. the second order taylor expansion is more precise up to at least 1e-5. Closes gh-4720
Diffstat (limited to 'numpy/random/tests/test_random.py')
-rw-r--r--numpy/random/tests/test_random.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index ef4e7b127..b64c9d6cd 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -629,6 +629,12 @@ class TestRandomDist(TestCase):
[ 1.19153771588353052, 1.83509849681825354]])
np.testing.assert_array_almost_equal(actual, desired, decimal=15)
+ def test_vonmises_small(self):
+ # check infinite loop, gh-4720
+ np.random.seed(self.seed)
+ r = np.random.vonmises(mu=0., kappa=1.1e-8, size=10**6)
+ np.testing.assert_(np.isfinite(r).all())
+
def test_wald(self):
np.random.seed(self.seed)
actual = np.random.wald(mean = 1.23, scale = 1.54, size = (3, 2))