def test_stat_quantiles(self): rng = RandomNumberGenerator() rng.setState("0123456789ABCDEF") v = DoubleVector() for i in range(100000): v.append(rng.getDouble( )) self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2) self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2) self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2) self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2) self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2)
def test_rng_state(self): rng = RandomNumberGenerator() with self.assertRaises(ValueError): rng.setState("12") rng.setState("0123456789ABCDEF") val1 = rng.getInt() val2 = rng.getInt() self.assertFalse( val1 == val2 ) rng.setState("0123456789ABCDEF") self.assertEqual( rng.getInt() , val1) self.assertEqual( rng.getInt() , val2)
def test_load_save(self): rng = RandomNumberGenerator() with self.assertRaises(IOError): rng.loadState("does/not/exist") with TestAreaContext("rng_state") as t: rng.saveState("rng.txt") t.sync() val1 = rng.getInt() val2 = rng.getInt() rng.loadState("rng.txt") self.assertEqual(rng.getInt(), val1) self.assertEqual(rng.getInt(), val2)
def setUp(self): self.rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) self.libname = ert.ert_lib_path + "/std_enkf_debug.so" self.module = AnalysisModule(self.rng, lib_name=self.libname)
def createAnalysisModule(self): rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) return AnalysisModule(rng, self.user, self.libname)
def setUp(self): self.libname = ert.ert_lib_path + "/rml_enkf.so" self.rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT)
def setUp(self): self.rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) self.module = AnalysisModule(self.rng, name="STD_ENKF")
def test_rng_default(self): rng = RandomNumberGenerator() self.assertIsInstance(rng.getDouble(), float)
def test_rng(self): rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_CLOCK) self.assertIsInstance(rng.getDouble(), float)