Пример #1
0
 def test_add_past_phases(self, jhu_data, population_data):
     scenario = Scenario(jhu_data, population_data, country="India")
     scenario.delete()
     # Phase series
     scenario.clear(name="Medicine")
     scenario.add(days=100)
     scenario.delete(name="Medicine")
     with pytest.raises(TypeError):
         scenario.delete(phase="0th")
     with pytest.raises(TypeError):
         scenario.summary(columns="Population")
     with pytest.raises(KeyError):
         scenario.summary(columns=["Value"])
     # Range of past phases
     scenario.first_date = "01Mar2020"
     scenario.first_date
     scenario.last_date = "16Jul2020"
     scenario.last_date
     with pytest.raises(ValueError):
         scenario.first_date = "01Aug2020"
     with pytest.raises(ValueError):
         scenario.last_date = "01Feb2020"
     # With trend analysis
     scenario.trend(set_phases=True)
     with pytest.raises(ValueError):
         scenario.trend(set_phases=False, n_points=3)
     scenario.combine(phases=["3rd", "4th"])
     scenario.separate(date="30May2020", phase="1st")
     scenario.delete(phases=["1st"])
     scenario.trend(set_phases=False)
     trend_df = scenario.summary()
     assert len(trend_df) == 4
     # add scenarios one by one
     scenario.clear(include_past=True)
     scenario.add(end_date="29May2020")
     scenario.add(end_date="05Jun2020").delete(phases=["0th"])
     scenario.add(end_date="15Jun2020")
     scenario.add(end_date="04Jul2020")
     scenario.add()
     one_df = scenario.summary()
     assert len(one_df) == 4
     # With 0th phase
     scenario.use_0th = True
     scenario.trend(set_phases=False, include_init_phase=True)
     scenario.use_0th = False
     scenario.trend(set_phases=True, include_init_phase=True)
     scenario.delete(phases=["0th"])
     assert len(scenario.summary()) == 5
     with pytest.raises(TypeError):
         scenario.delete(phases="1st")
Пример #2
0
 def test_edit(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)
     # Combine
     length = len(snl["Main"])
     snl.combine(["1st", "2nd"])
     n_changed = int(population_data.value(country) * 0.98)
     snl.combine(["2nd", "3rd"], population=n_changed)
     assert len(snl["Main"]) == length - 2
     # Separate
     snl.separate(date="01May2020")
     assert len(snl["Main"]) == length - 1