def test_ReduceR0_constructor_fullrange(self): config.set_file(f"{DATA_DIR}/test_ReduceR0_trivial.yml") test_result = ReduceR0(global_config = config["trivial"],npi_config = config["daterange"]["interventions"]["settings"]["Test"],geoids = ["10001","2020","40"]) assert type(test_result.get()).__module__ == 'pandas.core.frame' assert test_result.get().shape == (3,1) assert (test_result.get().keys() == pd.date_range(config["trivial"]["start_date"].as_date(), config["trivial"]["end_date"].as_date())).all() assert (test_result.get().index.values == ["10001","2020","40"]).all()
def test_ReduceR0_constructor_trivial(self): config.set_file(f"{DATA_DIR}/test_ReduceR0_trivial.yml") global_config = config["trivial_global"] test_result = ReduceR0(global_config = global_config, npi_config = config["trivial"], geoids = ["10001"]) assert type(test_result.getReduction('r0')).__module__ == 'pandas.core.frame' assert test_result.getReduction('r0').shape == (1,1) assert (test_result.getReduction('r0').keys() == [global_config["start_date"].as_date()]).all() assert (test_result.getReduction('r0').index.values == ["10001"])
def test_ReduceR0_constructor_geoidrange(self): config.set_file(f"{DATA_DIR}/test_ReduceR0_trivial.yml") global_config = config["trivial_global"] test_result = ReduceR0(global_config = global_config, npi_config = config["geoidrange"], geoids = ["10001","2020","40"]) reduction = test_result.getReduction('r0') assert type(reduction).__module__ == 'pandas.core.frame' assert reduction.shape == (3,1) assert (reduction.keys() == [global_config["start_date"].as_date()]).all() assert (reduction.index.values == ["10001","2020","40"]).all() assert (reduction.index.values == ["10001", "2020", "40"]).all() assert (reduction.loc[["10001", "2020"]] == 0.5).all(axis=None) assert (reduction.loc["40"] == 0).all()
def test_ReduceR0_constructor_fullrange(self): # Test affected geoids and period date range config.set_file(f"{DATA_DIR}/test_ReduceR0_trivial.yml") global_config = config["month_global"] npi_config = config["fullrange"] test_result = ReduceR0(global_config = global_config, npi_config = npi_config, geoids = ["10001","2020","40"]) reduction = test_result.getReduction('r0') assert type(reduction).__module__ == 'pandas.core.frame' assert reduction.shape == (3,32) assert (reduction.keys() == pd.date_range(global_config["start_date"].as_date(), global_config["end_date"].as_date())).all() assert (reduction.index.values == ["10001","2020","40"]).all() assert (reduction.loc[["10001","2020"],pd.date_range(npi_config["period_start_date"].as_date(), npi_config["period_end_date"].as_date())] == 0.5).all(axis=None)
def test_ReduceR0_constructor_daterange(self): # Test period date range config.set_file(f"{DATA_DIR}/test_ReduceR0_trivial.yml") global_config = config["month_global"] npi_config = config["daterange"] test_result = ReduceR0(global_config = global_config, npi_config = npi_config, geoids = ["10001"]) reduction = test_result.getReduction('r0') global_start_date = global_config["start_date"].as_date() global_end_date = global_config["end_date"].as_date() period_start_date = npi_config["period_start_date"].as_date() period_end_date = npi_config["period_end_date"].as_date() assert type(reduction).__module__ == 'pandas.core.frame' assert reduction.shape == (1,32) assert (reduction.keys() == pd.date_range(global_start_date, global_end_date)).all() assert (reduction.index.values == ["10001"]) # Test values in date ranges assert (reduction[pd.date_range(global_start_date, period_start_date, closed="left")] == 0).all(axis=None) assert (reduction[pd.date_range(period_start_date, period_end_date)] == 0.5).all(axis=None) assert (reduction[pd.date_range(period_end_date, global_end_date, closed="right")] == 0).all(axis=None)