コード例 #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")
コード例 #2
0
 def test_jhu(self):
     data_loader = DataLoader("input")
     jhu_data = data_loader.jhu()
     assert isinstance(jhu_data, JHUData)
     assert isinstance(jhu_data.citation, str)
     df = jhu_data.cleaned()
     assert isinstance(df, pd.DataFrame)
     assert set(df.columns) == set(Word.COLUMNS)
コード例 #3
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)
コード例 #4
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)
コード例 #5
0
 def test_oxcgrt(self):
     data_loader = DataLoader("input")
     oxcgrt_data = data_loader.oxcgrt()
     assert isinstance(oxcgrt_data, OxCGRTData)
     assert isinstance(oxcgrt_data.citation, str)
     df = oxcgrt_data.cleaned()
     assert isinstance(df, pd.DataFrame)
     assert set(df.columns) == set(OxCGRTData.OXCGRT_COLS)
     subset_cols_set = set(OxCGRTData.OXCGRT_COLS_WITHOUT_COUNTRY)
     subset_df = oxcgrt_data.subset(country="Japan")
     assert set(subset_df.columns) == subset_cols_set
     subset_df_iso = oxcgrt_data.subset(iso3="JPN")
     assert set(subset_df_iso.columns) == subset_cols_set
コード例 #6
0
 def test_dataloader(self, jhu_data, population_data, oxcgrt_data,
                     japan_data, linelist_data, pcr_data, vaccine_data):
     # List of primary sources of COVID-19 Data Hub
     data_loader = DataLoader()
     assert data_loader.covid19dh_citation
     # Data loading
     assert isinstance(jhu_data, JHUData)
     assert isinstance(population_data, PopulationData)
     assert isinstance(oxcgrt_data, OxCGRTData)
     assert isinstance(japan_data, CountryData)
     assert isinstance(linelist_data, LinelistData)
     assert isinstance(pcr_data, PCRData)
     assert isinstance(vaccine_data, VaccineData)
     # Local file
     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.pcr(local_file="input/covid19dh.csv")
コード例 #7
0
def jhu_data():
    data_loader = DataLoader("input")
    return data_loader.jhu()
コード例 #8
0
 def test_start(self):
     with pytest.raises(TypeError):
         DataLoader(directory=0)
コード例 #9
0
ファイル: conftest.py プロジェクト: kouyurin/covid19-sir
def jhu_data():
    data_loader = DataLoader()
    return data_loader.jhu()
コード例 #10
0
def data_loader():
    return DataLoader()
コード例 #11
0
def oxcgrt_data():
    data_loader = DataLoader("input")
    return data_loader.oxcgrt()
コード例 #12
0
 def test_oxcgrt_local_file_unexpected(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "covid_jpn_total.csv"
     with pytest.raises(Exception):
         data_loader.oxcgrt(local_file=local_path)
コード例 #13
0
 def test_oxcgrt_local_file(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "OxCGRT_latest.csv"
     data_loader.oxcgrt(local_file=local_path)
     local_file = str(local_path)
     data_loader.oxcgrt(local_file=local_file)
コード例 #14
0
 def test_subset(self):
     data_loader = DataLoader("input")
     jhu_data = data_loader.jhu()
     df = jhu_data.subset("Japan")
     assert isinstance(df, pd.DataFrame)
     assert set(df.columns) == set(Word.NLOC_COLUMNS)
コード例 #15
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)
コード例 #16
0
def japan_data():
    data_loader = DataLoader("input")
    return data_loader.japan()
コード例 #17
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)
コード例 #18
0
def population_data():
    data_loader = DataLoader("input")
    return data_loader.population()
コード例 #19
0
 def test_jhu_local_file(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "covid_19_data.csv"
     data_loader.jhu(local_file=local_path)
     local_file = str(local_path)
     data_loader.jhu(local_file=local_file)
コード例 #20
0
def data_loader():
    return DataLoader("input")
コード例 #21
0
ファイル: conftest.py プロジェクト: kouyurin/covid19-sir
def japan_data():
    data_loader = DataLoader()
    return data_loader.japan()
コード例 #22
0
ファイル: test_data_loader.py プロジェクト: adib5/covid19-sir
 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)
コード例 #23
0
 def test_jhu_local_file_unexpected(self):
     data_loader = DataLoader("input")
     local_path = Path("input") / "covid_jpn_total.csv"
     with pytest.raises(KeyError):
         data_loader.jhu(local_file=local_path)