def check_cpp_support(): from gillespy2.example_models import Example try: model = Example() solver = SSACSolver(model) results = model.run(solver=solver) model = Example() results = model.run(solver=SSACSolver) return True except: return False
def test_run_example(self): model = Example() for i in [1, self.number_of_trajectories]: for label in [True, False]: with self.subTest(number_of_trajectories=i, show_labels=label): if i > 1: with self.assertWarns(Warning): results = model.run(solver=BasicODESolver, show_labels=label, number_of_trajectories=i) else: results = model.run(solver=BasicODESolver, show_labels=label, number_of_trajectories=i) self.assertEqual(len(results), i) self.assertTrue( all([ isinstance(result, dict if label else np.ndarray) for result in results ])) if label: result = results[0] for species in model.listOfSpecies.keys(): self.assertIn(species, result.keys()) self.assertIsInstance(result[species], np.ndarray) self.assertListEqual(list(result[species].shape), list(model.tspan.shape)) else: self.assertIsInstance(results, np.ndarray) self.assertListEqual(list(results.shape), [ i, len(model.tspan), len(model.listOfSpecies.keys()) + 1 ]) for result in results[1:]: if label: self.assertDictEqual(results[0], result) else: self.assertTrue(np.array_equal(results[0], result))
def test_run_example(self): model = Example() for i in [1, self.number_of_trajectories]: for label in [True, False]: with self.subTest(number_of_trajectories=i, show_labels=label): if i > 1: with self.assertWarns(Warning): results = model.run(solver=BasicODESolver, show_labels=label, number_of_trajectories=i) self.assertEqual(len(results), i) else: results = model.run(solver=BasicODESolver, show_labels=label, number_of_trajectories=i) if i > 1 or not label: for result in results[1:]: if label: self.assertEqual(results[0], result) else: self.assertTrue( np.array_equal(results[0], result))
def test_extraneous_args(self): for solver in self.solvers: print(solver.name) with self.assertWarns(Warning): model = Example() results = model.run(solver=solver, nonsense='ABC')
def test_run_example(self): if can_use_cython: model = Example() results = model.run(solver=CythonSSASolver)
def test_run_example(self): model = Example() results = model.run(solver=NumPySSASolver)
def test_run_example_precompiled(self): model = Example() solver = SSACSolver(model) results = model.run(solver=solver)
def test_run_example(self): model = Example() results = model.run(solver=BasicTauLeapingSolver)
def test_run_example(self): model = Example() results = model.run(solver=BasicTauHybridSolver)