diff options
author | Antony Lee <anntzer.lee@gmail.com> | 2015-05-01 22:30:48 -0700 |
---|---|---|
committer | Antony Lee <anntzer.lee@gmail.com> | 2016-04-06 19:19:40 -0700 |
commit | bae9aebaa5aeedc3e1ecf69bef65f5fe721a3d37 (patch) | |
tree | b834830f4ea69cf7c3e818d80e6640e141bcdb5a /numpy/random/tests/test_random.py | |
parent | ac21efdd9d5d69198bc0802645826a4b1240952a (diff) | |
download | numpy-bae9aebaa5aeedc3e1ecf69bef65f5fe721a3d37.tar.gz |
Allow many distributions to have a scale of 0.
(in which case a stream of 0's is usually returned (or 1's)).
See #5818.
Diffstat (limited to 'numpy/random/tests/test_random.py')
-rw-r--r-- | numpy/random/tests/test_random.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py index a07fa52f5..3f4952d20 100644 --- a/numpy/random/tests/test_random.py +++ b/numpy/random/tests/test_random.py @@ -481,6 +481,9 @@ class TestRandomDist(TestCase): [0.68717433461363442, 1.69175666993575979]]) assert_array_almost_equal(actual, desired, decimal=15) + def test_exponential_0(self): + assert_equal(np.random.exponential(scale=0), 0) + def test_f(self): np.random.seed(self.seed) actual = np.random.f(12, 77, size=(3, 2)) @@ -497,6 +500,9 @@ class TestRandomDist(TestCase): [31.71863275789960568, 33.30143302795922011]]) assert_array_almost_equal(actual, desired, decimal=14) + def test_gamma_0(self): + assert_equal(np.random.gamma(shape=0, scale=0), 0) + def test_geometric(self): np.random.seed(self.seed) actual = np.random.geometric(.123456789, size=(3, 2)) @@ -513,6 +519,9 @@ class TestRandomDist(TestCase): [1.10651090478803416, -0.69535848626236174]]) assert_array_almost_equal(actual, desired, decimal=15) + def test_gumbel_0(self): + assert_equal(np.random.gumbel(scale=0), 0) + def test_hypergeometric(self): np.random.seed(self.seed) actual = np.random.hypergeometric(10.1, 5.5, 14, size=(3, 2)) @@ -547,6 +556,9 @@ class TestRandomDist(TestCase): [-0.05391065675859356, 1.74901336242837324]]) assert_array_almost_equal(actual, desired, decimal=15) + def test_laplace_0(self): + assert_equal(np.random.laplace(scale=0), 0) + def test_logistic(self): np.random.seed(self.seed) actual = np.random.logistic(loc=.123456789, scale=2.0, size=(3, 2)) @@ -555,6 +567,9 @@ class TestRandomDist(TestCase): [-0.21682183359214885, 2.63373365386060332]]) assert_array_almost_equal(actual, desired, decimal=15) + def test_laplace_0(self): + assert_(np.random.laplace(scale=0) in [0, 1]) + def test_lognormal(self): np.random.seed(self.seed) actual = np.random.lognormal(mean=.123456789, sigma=2.0, size=(3, 2)) @@ -563,6 +578,9 @@ class TestRandomDist(TestCase): [65.72798501792723869, 86.84341601437161273]]) assert_array_almost_equal(actual, desired, decimal=13) + def test_lognormal_0(self): + assert_equal(np.random.lognormal(sigma=0), 1) + def test_logseries(self): np.random.seed(self.seed) actual = np.random.logseries(p=.923456789, size=(3, 2)) @@ -653,6 +671,9 @@ class TestRandomDist(TestCase): [4.18552478636557357, 4.46410668111310471]]) assert_array_almost_equal(actual, desired, decimal=15) + def test_normal_0(self): + assert_equal(np.random.normal(scale=0), 0) + def test_pareto(self): np.random.seed(self.seed) actual = np.random.pareto(a=.123456789, size=(3, 2)) @@ -700,6 +721,9 @@ class TestRandomDist(TestCase): [11.06066537006854311, 17.35468505778271009]]) assert_array_almost_equal(actual, desired, decimal=14) + def test_rayleigh_0(self): + assert_equal(np.random.rayleigh(scale=0), 0) + def test_standard_cauchy(self): np.random.seed(self.seed) actual = np.random.standard_cauchy(size=(3, 2)) @@ -724,6 +748,9 @@ class TestRandomDist(TestCase): [7.54838614231317084, 8.012756093271868]]) assert_array_almost_equal(actual, desired, decimal=14) + def test_standard_gamma_0(self): + assert_equal(np.random.standard_gamma(shape=0), 0) + def test_standard_normal(self): np.random.seed(self.seed) actual = np.random.standard_normal(size=(3, 2)) @@ -799,6 +826,9 @@ class TestRandomDist(TestCase): [0.67057783752390987, 1.39494046635066793]]) assert_array_almost_equal(actual, desired, decimal=15) + def test_weibull_0(self): + assert_equal(np.random.weibull(a=0), 0) + def test_zipf(self): np.random.seed(self.seed) actual = np.random.zipf(a=1.23, size=(3, 2)) |