Esempio n. 1
0
 def test_dataloader(self):
     # Create DataLoader instance
     with pytest.raises(TypeError):
         DataLoader(directory=0)
     data_loader = DataLoader(directory="input", update_interval=12)
     # List of primary sources of COVID-19 Data Hub
     assert data_loader.covid19dh_citation
     # Data loading
     assert isinstance(data_loader.jhu(), JHUData)
     assert isinstance(data_loader.population(), PopulationData)
     assert isinstance(data_loader.oxcgrt(), OxCGRTData)
     assert isinstance(data_loader.japan(), CountryData)
     # With local files
     data_loader.jhu(local_file="input/covid19dh.csv")
     data_loader.population(local_file="input/covid19dh.csv")
     data_loader.oxcgrt(local_file="input/covid19dh.csv")
     data_loader.japan(local_file="input/covid_jpn_total.csv")
Esempio n. 2
0
 def test_japan_cases(self):
     data_loader = DataLoader("input")
     japan_data = data_loader.japan()
     assert isinstance(japan_data, CountryData)
     assert isinstance(japan_data.citation, str)
     df = japan_data.cleaned()
     assert isinstance(df, pd.DataFrame)
     assert set(df.columns) == set(Word.COLUMNS)
Esempio n. 3
0
 def test_replace(self):
     data_loader = DataLoader("input")
     jhu_data = data_loader.jhu()
     japan_data = data_loader.japan()
     jhu_data.replace(japan_data)
     assert isinstance(jhu_data, JHUData)
     replaced_df = jhu_data.subset("Japan")
     japan_df = japan_data.cleaned()
     assert set(replaced_df.columns) == set(Word.NLOC_COLUMNS)
     assert len(replaced_df) == len(japan_df)
Esempio n. 4
0
 def test_japan_cases_local_file_unexpected(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "covid19dh.csv"
     with pytest.raises(Exception):
         warnings.filterwarnings("ignore", category=pd.errors.DtypeWarning)
         data_loader.japan(local_file=local_path)
Esempio n. 5
0
def japan_data():
    data_loader = DataLoader("input")
    return data_loader.japan()
Esempio n. 6
0
def japan_data():
    data_loader = DataLoader()
    return data_loader.japan()
Esempio n. 7
0
 def test_japan_cases_local_file_unexpected(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "covid_19_data.csv"
     with pytest.raises(Exception):
         data_loader.japan(local_file=local_path)
Esempio n. 8
0
 def test_japan_cases_local_file(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "covid_jpn_total.csv"
     data_loader.japan(local_file=local_path)
     local_file = str(local_path)
     data_loader.japan(local_file=local_file)