コード例 #1
0
ファイル: __init__.py プロジェクト: juhjuh/GillesPy2
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
コード例 #2
0
 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))
コード例 #3
0
    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))
コード例 #4
0
 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')
コード例 #5
0
 def test_run_example(self):
     if can_use_cython:
         model = Example()
         results = model.run(solver=CythonSSASolver)
コード例 #6
0
 def test_run_example(self):
     model = Example()
     results = model.run(solver=NumPySSASolver)
コード例 #7
0
 def test_run_example_precompiled(self):
     model = Example()
     solver = SSACSolver(model)
     results = model.run(solver=solver)
コード例 #8
0
 def test_run_example(self):
     model = Example()
     results = model.run(solver=BasicTauLeapingSolver)
コード例 #9
0
 def test_run_example(self):
     model = Example()
     results = model.run(solver=BasicTauHybridSolver)