def test_simulate(self, jhu_data, population_data, country): # Dataset population = population_data.value(country) record_df = jhu_data.subset(country, population=population) # Parameter setting unit = PhaseUnit("27May2020", "27Jun2020", population) with pytest.raises(UnExecutedError): unit3 = PhaseUnit("27May2020", "27Jun2020", population) unit3.set_ode(model=SIR, tau=240, rho=0.006) unit3.simulate() unit.set_ode(model=SIR, tau=240, rho=0.006, sigma=0.011) summary_dict = unit.to_dict() assert summary_dict[Term.RT] == 0.55 assert summary_dict["1/beta [day]"] == 27 assert summary_dict["1/gamma [day]"] == 15 # Set initial values unit.set_y0(record_df) # Simulation sim_df = unit.simulate() assert set(sim_df.columns) == set(Term.NLOC_COLUMNS)
def test_simulate_y0_direct(self, jhu_data, population_data, country): # Dataset population = population_data.value(country) # Parameter setting unit = PhaseUnit("27May2020", "27Jun2020", population) unit.set_ode(model=SIR, tau=240, rho=0.006, sigma=0.011) # Simulation y0_dict = { "Susceptible": 126512455, "Infected": 1806, "Fatal or Recovered": 14839 } sim_df = unit.simulate(y0_dict=y0_dict) assert set(sim_df.columns) == set(Term.NLOC_COLUMNS)