Esempio n. 1
0
    def test_exceptions(self):

        B, mu, t = sympy.symbols("B mu t")
        epi = SymbolicEpiModel([B])
        epi.add_fission_processes([
            (B, mu, B, B),
        ])
        epi.set_initial_conditions({B: 1})

        self.assertRaises(ValueError, epi.integrate, [0, 1])

        self.assertRaises(ValueError, SymbolicEpiModel, [t])

        self.assertRaises(ValueError,
                          epi.get_eigenvalues_at_disease_free_state)
Esempio n. 2
0
    def test_time_dependent_rates(self):

        B, t = sympy.symbols("B t")
        epi = SymbolicEpiModel([B])
        epi.add_fission_processes([
            (B, t, B, B),
        ])
        epi.set_initial_conditions({B: 1})
        result = epi.integrate([0, 3], adopt_final_state=True)
        assert (np.isclose(epi.y0[0], np.exp(3**2 / 2)))
        epi.set_initial_conditions({B: 1})
        result = epi.integrate(np.linspace(0, 3, 10000),
                               integrator='euler',
                               adopt_final_state=True)
        eul = epi.y0[0]
        real = np.exp(3**2 / 2)
        assert (np.abs(1 - eul / real) < 1e-2)