summaryrefslogtreecommitdiff
path: root/numpy/random/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/random/tests')
-rw-r--r--numpy/random/tests/test_random.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py
index 013205835..a06de58e3 100644
--- a/numpy/random/tests/test_random.py
+++ b/numpy/random/tests/test_random.py
@@ -485,6 +485,10 @@ 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)
+ assert_raises(ValueError, np.random.exponential, scale=-0.)
+
def test_f(self):
np.random.seed(self.seed)
actual = np.random.f(12, 77, size=(3, 2))
@@ -501,6 +505,10 @@ 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)
+ assert_raises(ValueError, np.random.gamma, shape=-0., scale=-0.)
+
def test_geometric(self):
np.random.seed(self.seed)
actual = np.random.geometric(.123456789, size=(3, 2))
@@ -517,6 +525,10 @@ 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)
+ assert_raises(ValueError, np.random.gumbel, scale=-0.)
+
def test_hypergeometric(self):
np.random.seed(self.seed)
actual = np.random.hypergeometric(10.1, 5.5, 14, size=(3, 2))
@@ -551,6 +563,10 @@ 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)
+ assert_raises(ValueError, np.random.laplace, scale=-0.)
+
def test_logistic(self):
np.random.seed(self.seed)
actual = np.random.logistic(loc=.123456789, scale=2.0, size=(3, 2))
@@ -559,6 +575,10 @@ 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])
+ assert_raises(ValueError, np.random.laplace, scale=-0.)
+
def test_lognormal(self):
np.random.seed(self.seed)
actual = np.random.lognormal(mean=.123456789, sigma=2.0, size=(3, 2))
@@ -567,6 +587,10 @@ 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)
+ assert_raises(ValueError, np.random.lognormal, sigma=-0.)
+
def test_logseries(self):
np.random.seed(self.seed)
actual = np.random.logseries(p=.923456789, size=(3, 2))
@@ -657,6 +681,10 @@ 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)
+ assert_raises(ValueError, np.random.normal, scale=-0.)
+
def test_pareto(self):
np.random.seed(self.seed)
actual = np.random.pareto(a=.123456789, size=(3, 2))
@@ -704,6 +732,10 @@ 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)
+ assert_raises(ValueError, np.random.rayleigh, scale=-0.)
+
def test_standard_cauchy(self):
np.random.seed(self.seed)
actual = np.random.standard_cauchy(size=(3, 2))
@@ -728,6 +760,10 @@ 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)
+ assert_raises(ValueError, np.random.standard_gamma, shape=-0.)
+
def test_standard_normal(self):
np.random.seed(self.seed)
actual = np.random.standard_normal(size=(3, 2))
@@ -803,6 +839,10 @@ 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)
+ assert_raises(ValueError, np.random.weibull, a=-0.)
+
def test_zipf(self):
np.random.seed(self.seed)
actual = np.random.zipf(a=1.23, size=(3, 2))