def test_one_phase_with_few_records(self, jhu_data, population_data): population = population_data.value("Italy") sr_df = jhu_data.to_sr(country="Italy", population=population, start_date="25Mar2020", end_date="26Mar2020") with pytest.raises(ValueError): trend = Trend(sr_df) trend.run()
def test_one_phase_rmsle_without_analyse(self, jhu_data, population_data): population = population_data.value("Italy") trend = Trend(jhu_data, population, "Italy", start_date="25Mar2020", end_date="02Apr2020") with pytest.raises(NameError): trend.rmsle()
def test_one_phase(self, jhu_data, population_data, country, func): population = population_data.value(country) sr_df = jhu_data.to_sr(country=country, population=population, start_date="25Mar2020", end_date="02Apr2020") trend = Trend(sr_df) assert isinstance(trend.rmsle(), float) trend.show(area=jhu_data.area_name(country="Italy"))
def test_one_phase_with_few_records(self, jhu_data, population_data): population = population_data.value("Italy") clean_df = jhu_data.subset("Italy") clean_df[Term.COUNTRY] = "Italy" clean_df[Term.PROVINCE] = Term.UNKNOWN clean_df = clean_df.iloc[:2, :] warnings.filterwarnings("ignore", category=DeprecationWarning) with pytest.raises(ValueError): _ = Trend(clean_df, population, "Italy")
def test_one_phase_with_few_records(self, jhu_data, population_data, country): warnings.simplefilter("ignore", category=UserWarning) population = population_data.value(country) sr_df = jhu_data.to_sr(country=country, population=population, start_date="25Mar2020", end_date="26Mar2020") with pytest.raises(ValueError): Trend(sr_df).run()
def test_one_phase(self, jhu_data, population_data): population = population_data.value("Italy") trend = Trend(jhu_data, population, "Italy", start_date="25Mar2020", end_date="02Apr2020") trend.analyse() assert isinstance(trend.rmsle(), float) trend.show()
def test_one_phase(self, jhu_data, population_data): population = population_data.value("Italy") sr_df = jhu_data.to_sr(country="Italy", population=population, start_date="25Mar2020", end_date="02Apr2020") trend = Trend(sr_df) trend.run() assert isinstance(trend.rmsle(), float) warnings.simplefilter("ignore", category=UserWarning) trend.show(area=jhu_data.area_name(country="Italy"))
def test_one_phase_with_dataframe(self, jhu_data, population_data): population = population_data.value("Italy") clean_df = jhu_data.cleaned() warnings.filterwarnings("ignore", category=DeprecationWarning) trend = Trend(clean_df, population, "Italy", start_date="25Mar2020", end_date="02Apr2020") trend.analyse() assert isinstance(trend.rmsle(), float) trend.show()
def test_find(self, jhu_data, population_data, country, max_rmsle=20.0): # Setup population = population_data.value(country) sr_df = jhu_data.to_sr(country=country, population=population) # Find change points change_finder = ChangeFinder(sr_df, max_rmsle=max_rmsle) change_finder.run() # For all phases, check if RMSLE score is lower than max_rmsle=20.0 for (start_date, end_date) in zip(*change_finder.date_range()): phase_df = jhu_data.to_sr(country=country, population=population, start_date=start_date, end_date=end_date) rmsle = Trend(sr_df=phase_df).rmsle() assert rmsle < max_rmsle
def test_min_size(self, jhu_data, population_data, country): # Dataset population = population_data.value(country) subset_df = jhu_data.subset(country=country, population=population) # Too small min_size with pytest.raises(ValueError): TrendDetector(data=subset_df, min_size=2) # Too large min_size with pytest.raises(ValueError): TrendDetector(data=subset_df, min_size=100000) # Reset detector = TrendDetector(data=subset_df) detector.reset() # Deprecated warnings.filterwarnings("ignore", category=DeprecationWarning) ChangeFinder(subset_df) Trend(subset_df)