def test_estimate(self, jhu_data, population_data, country): warnings.simplefilter("ignore", category=UserWarning) # Setting snl = Scenario(jhu_data, population_data, country) snl.first_date = "01Apr2020" snl.last_date = "01Aug2020" with pytest.raises(ValueError): snl.estimate(SIR) snl.trend(include_init_phase=True, show_figure=False) snl.disable(phases=["0th"]) with pytest.raises(AttributeError): snl.estimate_history(phase="1th") # Parameter estimation with pytest.raises(KeyError): snl.estimate(SIR, phases=["30th"]) with pytest.raises(ValueError): snl.estimate(model=SIR, tau=1440) snl.enable(phases=["0th"]) with pytest.raises(TypeError): snl.estimate(model=SIR, phases="1st") with pytest.raises(ValueError): snl.estimate(model=SIR, phases=["0th"]) snl.clear(include_past=True) snl.trend(show_figure=False) snl.estimate(SIR) # Estimation history snl.estimate_history(phase="1st") # Estimation accuracy snl.estimate_accuracy(phase="1st") # Get a value snl.get(Term.RT) with pytest.raises(KeyError): snl.get("feeling")
def test_trend(self, jhu_data, population_data, country): # Setting snl = Scenario(jhu_data, population_data, country) snl.first_date = "01Apr2020" snl.last_date = "01Aug2020" # Deprecated warnings.simplefilter("error") with pytest.raises(DeprecationWarning): snl.trend(include_init_phase=False, show_figure=False) warnings.simplefilter("ignore") snl.trend(include_init_phase=False, show_figure=False) # S-R trend analysis snl.trend(show_figure=False) assert snl["Main"] with pytest.raises(ValueError): snl.trend(show_figure=False, n_points=3) # Disable/enable length = len(snl["Main"]) snl.disable(phases=["0th"], name="Main") assert len(snl["Main"]) == length - 1 snl.enable(phases=["0th"], name="Main") assert len(snl["Main"]) == length with pytest.raises(TypeError): snl.enable(phases="0th", name="Main") with pytest.raises(TypeError): snl.disable(phases="1st", name="Main")
def test_simulate(self, jhu_data, population_data, country): warnings.simplefilter("ignore", category=UserWarning) warnings.simplefilter("ignore", category=DeprecationWarning) # Setting snl = Scenario(jhu_data, population_data, country) snl.first_date = "01Apr2020" snl.last_date = "01May2020" with pytest.raises(ValueError): snl.simulate() with pytest.raises(ValueError): snl.track() snl.trend(show_figure=False) # Parameter estimation with pytest.raises(ValueError): # Deprecated snl.param_history(["rho"]) all_phases = snl.summary().index.tolist() snl.disable(all_phases[:-2]) with pytest.raises(NameError): snl.simulate() snl.estimate(SIRF, timeout=5, timeout_iteration=5) # Simulation snl.simulate(variables=[Term.C, Term.CI, Term.F, Term.R]) snl.simulate(phases=all_phases[-2:]) # Parameter history (Deprecated) snl.param_history([Term.RT], divide_by_first=False) snl.param_history(["rho"]) snl.param_history(["rho"], show_figure=False) snl.param_history(["rho"], show_box_plot=False) with pytest.raises(KeyError): snl.param_history(["feeling"]) # Comparison of scenarios snl.describe() snl.track() snl.history(target="Rt") snl.history(target="sigma") snl.history(target="rho", show_figure=False) snl.history(target="Infected", phases=all_phases[-2:]) with pytest.raises(KeyError): snl.history(target="temperature") # Change rate of parameters snl.history_rate(name="Main") snl.history_rate( name="Main", params=["theta", "kappa"], show_figure=False) with pytest.raises(TypeError): snl.history_rate(params="", name="Main") # Add new scenario snl.add(end_date="01Sep2020", name="New") snl.describe()
def test_trend(self, jhu_data, population_data, country): # Setting snl = Scenario(jhu_data, population_data, country) snl.first_date = "01Apr2020" snl.last_date = "01Aug2020" snl.trend(show_figure=False) assert snl["Main"] with pytest.raises(ValueError): snl.trend(show_figure=False, n_points=3) # Disable/enable length = len(snl["Main"]) snl.disable(phases=["0th"], name="Main") assert len(snl["Main"]) == length - 1 snl.enable(phases=["0th"], name="Main") assert len(snl["Main"]) == length with pytest.raises(TypeError): snl.enable(phases="0th", name="Main") with pytest.raises(TypeError): snl.disable(phases="1st", name="Main")
def test_score_error(self, jhu_data, population_data, country): snl = Scenario(jhu_data, population_data, country) with pytest.raises(ValueError): snl.score() snl.trend(show_figure=False) with pytest.raises(NameError): snl.score() all_phases = snl.summary().index.tolist() snl.disable(phases=all_phases[:-2]) snl.estimate(SIRF, timeout=10) with pytest.raises(TypeError): snl.score(phases="0th") with pytest.raises(KeyError): snl.score(phases=["100th"]) with pytest.raises(TypeError): snl.score(variables="Infected") with pytest.raises(KeyError): snl.score(variables=["Susceptible"]) with pytest.raises(ValueError): snl.score(metrics="Subjective evaluation") with pytest.raises(ValueError): snl.score(phases=["0th"], past_days=100)