示例#1
0
 def test_show_complement(self, jhu_data, population_data, country):
     # Setting
     dhl = DataHandler(jhu_data, population_data, country)
     dhl.init_records()
     dhl.first_date = "01Apr2020"
     dhl.last_date = "01Aug2020"
     # Test
     dhl_df = dhl.show_complement()
     data_df = jhu_data.show_complement(
         country=country, start_date="01Apr2020", end_date="01Aug2020")
     assert dhl_df.equals(data_df)
示例#2
0
 def test_line_plot(self, jhu_data, population_data, country):
     warnings.simplefilter("ignore", category=UserWarning)
     # Setting
     dhl = DataHandler(jhu_data, population_data, country)
     dhl.init_records()
     # Interactive / script mode
     assert not dhl.interactive
     with pytest.raises(NotInteractiveError):
         dhl.interactive = True
     dhl.interactive = False
     # Change colors in plotting
     dhl.records(
         variables=["Confirmed", "Infected", "Fatal", "Recovered"],
         color_dict={"Confirmed": "blue", "Infected": "orange", "Fatal": "red", "Recovered": "green"})
示例#3
0
 def test_start_record_range(self, jhu_data, population_data, country):
     # Setting
     dhl = DataHandler(jhu_data, population_data, country)
     dhl.init_records()
     # Test
     dhl.first_date = "01Apr2020"
     assert dhl.first_date == "01Apr2020"
     dhl.last_date = "01May2020"
     assert dhl.last_date == "01May2020"
     with pytest.raises(ValueError):
         dhl.first_date = "01Jan2019"
     with pytest.raises(ValueError):
         tomorrow = Term.tomorrow(datetime.now().strftime(Term.DATE_FORMAT))
         dhl.last_date = tomorrow
示例#4
0
 def test_records(self, jhu_data, population_data, country):
     warnings.simplefilter("ignore", category=UserWarning)
     # Setting
     dhl = DataHandler(jhu_data, population_data, country)
     dhl.init_records()
     dhl.first_date = "01Apr2020"
     dhl.last_date = "01Aug2020"
     # Test
     df = dhl.records(variables=None, show_figure=False)
     assert isinstance(df, pd.DataFrame)
     assert set(df.columns) == set([Term.DATE, Term.CI, Term.F, Term.R])
     dates = df[Term.DATE]
     assert dates.min() == Term.date_obj(dhl.first_date)
     assert dates.max() == Term.date_obj(dhl.last_date)
     df2 = dhl.records(variables=["Susceptible"], show_figure=True)
     assert set(df2.columns) == set([Term.DATE, Term.S])
示例#5
0
 def test_records_diff(self, jhu_data, population_data, country):
     warnings.simplefilter("ignore", category=UserWarning)
     dhl = DataHandler(jhu_data, population_data, country)
     dhl.init_records()
     dhl.records_diff(window=7, show_figure=False)
     dhl.records_diff(window=100, show_figure=True)