from numpy.testing import * import os set_local_path(os.path.join('..', '..')) import pyspkrec restore_path() import pyspkrec.random # TODO minstd_rand and minstd_rand0 don't like a zero seed class _test_rng: def test_uniform_smallint(self): rng = self.rng rng.seed(123) rng.uniform_smallint(0, 1) def test_uniform_int(self): rng = self.rng rng.seed(123) rng.uniform_int() def test_uniform_real(self): rng = self.rng rng.seed(123) rng.uniform_real() rng.uniform_real(min=0.5) rng.uniform_real(max=2.0) x = rng.uniform_real(size=(10,)) self.assertEqual(10, len(x)) def test_bernoulli(self): rng = self.rng rng.seed(123) rng.bernoulli() def test_geometric(self): rng = self.rng rng.seed(123) rng.geometric() def test_triangle(self): rng = self.rng rng.seed(123) rng.triangle(0.0, 1.0, 2.0) def test_exponential(self): rng = self.rng rng.seed(123) rng.exponential() def test_normal(self): rng = self.rng rng.seed(123) rng.normal() def test_lognormal(self): rng = self.rng rng.seed(123) rng.lognormal() class test_hellekalek1995(NumpyTestCase, _test_rng): rng = pyspkrec.random.hellekalek1995 class test_kreutzer1986(NumpyTestCase, _test_rng): rng = pyspkrec.random.kreutzer1986 class test_minstd_rand(NumpyTestCase, _test_rng): rng = pyspkrec.random.minstd_rand class test_minstd_rand0(NumpyTestCase, _test_rng): rng = pyspkrec.random.minstd_rand0 class test_mt11213b(NumpyTestCase, _test_rng): rng = pyspkrec.random.mt11213b class test_mt19937(NumpyTestCase, _test_rng): rng = pyspkrec.random.mt19937 class test_rand48(NumpyTestCase, _test_rng): rng = pyspkrec.random.rand48 if __name__ == '__main__': NumpyTest().run()