From 69e26e54edd3c83fae61e880a102d1b979e2d67d Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Wed, 28 May 2014 19:28:25 +0200 Subject: 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 --- numpy/random/tests/test_random.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'numpy/random/tests/test_random.py') 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)) -- cgit v1.2.1