def setUp(self): self.model = TEST_MODEL self.representation = [r.id for r in self.model.reactions] random = Random(SEED) args = {"representation": self.representation} self.solutions = BestSolutionArchive() for _ in range(10000): self.solutions.add(set_generator(random, args), random.random(), None, True, 100) self.decoder = ReactionKnockoutDecoder(self.representation, self.model)
def setUp(self): self.model = TEST_MODEL self.representation = [r.id for r in self.model.reactions] random = Random(SEED) args = {"representation": self.representation} self.solutions = BestSolutionArchive() for _ in range(10000): self.solutions.add(set_generator(random, args), random.random(), None, True, 100) self.decoder = ReactionSetDecoder(self.representation, self.model)
def test_seeded_methods(self): random = RandomGenerator() random.seed(SEED) value = random.random() random.seed(SEED) assert value == random.random() random.seed(SEED) value = random.randint(1, 10) random.seed(SEED) assert value == random.randint(1, 10) random.seed(SEED) population = [1, 2, 3, 4, 5] value = random.sample(population, 2) random.seed(SEED) assert value == random.sample(population, 2) random.seed(SEED) value = random.uniform() random.seed(SEED) assert value == random.uniform()
def test_seeded_methods(self): random = RandomGenerator() random.seed(self.seed) value = random.random() random.seed(self.seed) self.assertEqual(value, random.random()) random.seed(self.seed) value = random.randint(1, 10) random.seed(self.seed) self.assertEqual(value, random.randint(1, 10)) random.seed(self.seed) population = [1, 2, 3, 4, 5] value = random.sample(population, 2) random.seed(self.seed) self.assertEqual(value, random.sample(population, 2)) random.seed(self.seed) value = random.uniform() random.seed(self.seed) self.assertEqual(value, random.uniform())
def test_random(self): random = RandomGenerator() for _ in range(1000): assert random.random() >= 0 assert random.random() <= 1
def test_random(self): random = RandomGenerator() for _ in range(1000): self.assertGreaterEqual(random.random(), 0) self.assertLessEqual(random.random(), 1)