Example #1
0
def test_build_descriptions():
    param = copy(PARAM)

    admits_file = 'tests/by_doubling_time/2020-03-28_projected_admits.csv'
    census_file = 'tests/by_doubling_time/2020-03-28_projected_census.csv'

    admits_df = pd.read_csv(admits_file, parse_dates=['date'])
    chart = build_admits_chart(alt=alt, admits_df=admits_df)
    description = build_descriptions(chart=chart, labels=param.labels)

    hosp, icu, vent = description.split(
        "\n\n")  # break out the description into lines

    max_hosp = chart.data['hospitalized'].max()
    assert str(ceil(max_hosp)) in hosp

    # TODO add test for asterisk

    # test no asterisk
    param.n_days = 600

    admits_df = pd.read_csv(admits_file, parse_dates=['date'])
    chart = build_admits_chart(alt=alt, admits_df=admits_df)
    description = build_descriptions(chart=chart, labels=param.labels)
    assert "*" not in description

    # census chart
    census_df = pd.read_csv(census_file, parse_dates=['date'])
    chart = build_census_chart(alt=alt, census_df=census_df)
    description = build_descriptions(chart=chart, labels=param.labels)

    assert str(ceil(chart.data['ventilated'].max())) in description
    assert str(chart.data['icu'].idxmax()) not in description
    assert datetime.strftime(chart.data.iloc[chart.data['icu'].idxmax()].date,
                             '%b %d') in description
Example #2
0
def test_build_descriptions(admits_floor_df, param):
    chart = build_admits_chart(alt=alt, admits_floor_df=admits_floor_df)
    description = build_descriptions(chart=chart, labels=param.labels)

    hosp, icu, vent = description.split("\n\n")  # break out the description into lines

    max_hosp = chart.data["hospitalized"].max()
    assert str(ceil(max_hosp)) in hosp
Example #3
0
def test_census(census_df, param):
    chart = build_census_chart(alt=alt, census_df=census_df)
    description = build_descriptions(chart=chart, labels=param.labels)

    assert str(ceil(chart.data['ventilated'].max())) in description
    assert str(chart.data['icu'].idxmax()) not in description
    assert datetime.strftime(chart.data.iloc[chart.data['icu'].idxmax()].date,
                             '%b %d') in description
Example #4
0
def test_census(census_floor_df, param):
    chart = build_census_chart(alt=alt, census_floor_df=census_floor_df)
    description = build_descriptions(chart=chart, labels=param.labels)

    assert str(ceil(chart.data["ventilated"].max())) in description
    assert str(chart.data["icu"].idxmax()) not in description
    assert (
        datetime.strftime(chart.data.iloc[chart.data["icu"].idxmax()].date, "%b %d")
        in description
    )
Example #5
0
def test_no_asterisk(admits_floor_df, param):
    param.n_days = 600

    chart = build_admits_chart(alt=alt, admits_floor_df=admits_floor_df)
    description = build_descriptions(chart=chart, labels=param.labels)
    assert "*" not in description