diff options
author | Christoph Gohlke <cgohlke@uci.edu> | 2013-05-27 12:22:02 -0700 |
---|---|---|
committer | Christoph Gohlke <cgohlke@uci.edu> | 2013-05-27 16:17:00 -0700 |
commit | cec1d415840c5d028677ba705a2e0375dae75fc4 (patch) | |
tree | dc7f28a2996d18df7e5d116bbf0b5032145c004c /numpy/random/tests/test_regression.py | |
parent | b98eefccbf0b6f60414f87ce135e9bbd2bea5a3a (diff) | |
download | numpy-cec1d415840c5d028677ba705a2e0375dae75fc4.tar.gz |
BUG: Fix multivariate_normal issue with 'size' argument
Ensure that the multivariate_normal size argument can be a numpy integer. Add regression test. Apply PEP8 to test_regression.py. Regenerate mtrand.c.
Diffstat (limited to 'numpy/random/tests/test_regression.py')
-rw-r--r-- | numpy/random/tests/test_regression.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/numpy/random/tests/test_regression.py b/numpy/random/tests/test_regression.py index 70858b049..9e473f9b1 100644 --- a/numpy/random/tests/test_regression.py +++ b/numpy/random/tests/test_regression.py @@ -1,7 +1,7 @@ from __future__ import division, absolute_import, print_function -from numpy.testing import TestCase, run_module_suite, assert_,\ - assert_array_equal +from numpy.testing import (TestCase, run_module_suite, assert_, + assert_array_equal) from numpy import random from numpy.compat import long import numpy as np @@ -15,15 +15,15 @@ class TestRegression(TestCase): Regression test for ticket #986. """ for mu in np.linspace(-7., 7., 5): - r = random.mtrand.vonmises(mu,1,50) + r = random.mtrand.vonmises(mu, 1, 50) assert_(np.all(r > -np.pi) and np.all(r <= np.pi)) - def test_hypergeometric_range(self) : + def test_hypergeometric_range(self): """Test for ticket #921""" assert_(np.all(np.random.hypergeometric(3, 18, 11, size=10) < 4)) assert_(np.all(np.random.hypergeometric(18, 3, 11, size=10) > 0)) - def test_logseries_convergence(self) : + def test_logseries_convergence(self): """Test for ticket #923""" N = 1000 np.random.seed(0) @@ -76,5 +76,16 @@ class TestRegression(TestCase): # If m.state is not honored, the result will change assert_array_equal(m.choice(10, size=10, p=np.ones(10.)/10), res) + def test_multivariate_normal_size_types(self): + """Test for multivariate_normal issue with 'size' argument. + + Check that the multivariate_normal size argument can be a + numpy integer. + + """ + np.random.multivariate_normal([0], [[0]], size=1) + np.random.multivariate_normal([0], [[0]], size=np.int_(1)) + np.random.multivariate_normal([0], [[0]], size=np.int64(1)) + if __name__ == "__main__": run_module_suite() |