def testSingleRandom(self): shape = (9, 10, 11) rng = DcmtRandomState(gen_seed=900) rng.seed(400) r = rng.rand() self.assert_(type(r) == float)
def testRand(self): shape = (9, 10, 11) rng = DcmtRandomState(gen_seed=900) rng.seed(400) randoms = rng.rand(*shape) self.assert_(randoms.shape == shape) diff_mean, diff_var = testLimits(randoms, 0, 1) self.assert_(diff_mean < 0.05) self.assert_(diff_var < 0.05)
def testRandrawFill(self): shape = (9, 10, 11) rng = DcmtRandomState(gen_seed=900) rng.seed(400) wrong_val = "aaa" wrong_arr = numpy.empty(shape, numpy.int64) self.assertRaises(TypeError, rng.rand_fill, wrong_val) self.assertRaises(TypeError, rng.rand_fill, wrong_arr) for dtype in (numpy.int32, numpy.uint32, numpy.float32): randoms = numpy.empty(shape, dtype) rng.randraw_fill(randoms)
def testRandFill(self): shape = (9, 10, 11) rng = DcmtRandomState(gen_seed=900) rng.seed(400) wrong_val = "aaa" wrong_arr = numpy.empty(shape, numpy.float32) self.assertRaises(TypeError, rng.rand_fill, wrong_val) self.assertRaises(TypeError, rng.rand_fill, wrong_arr) randoms = numpy.empty(shape, numpy.float64) rng.rand_fill(randoms) diff_mean, diff_var = testLimits(randoms, 0, 1) self.assert_(diff_mean < 0.05) self.assert_(diff_var < 0.05)