def test_coarse_contact_matrix(self): m1 = contact_matrix('italy') m2 = contact_matrix('italy', coarse=True) assert abs(m1.values[:-1, :-1].sum() - m2.values[:-2, :-2].sum()) < 1e-3 assert list(m1.index) != list(m2.index) assert (m2.index == age_distribution('Italy', 2020, coarse=True).index).all()
def test_load_covid_mortality_syncs_with_age_distribution(self): dm = covid_mortality() df = age_distribution("Brazil", 2020, coarse=True) assert (dm.index == df.index).all()
def test_load_bad_age_distribution(self): with pytest.raises(ValueError): age_distribution("Brazil", 2050) with pytest.raises(ValueError): age_distribution("Bad spelling", 2050)
def test_load_age_distribution(self): df = age_distribution("Brazil", 2020) assert 209_000 <= df.sum() <= 220_000
import streamlit as st import covid from covid import gettext as _ from covid.data import countries from covid.models import SEICHAR from covid.utils import fmt, pc from covid.data import age_distribution TODAY = datetime.datetime.now() TODAY = datetime.date(TODAY.year, TODAY.month, TODAY.day) # Adjust demography to 2020. We only have citywise and statewise datasets # from the Brazilian Census of 2010. DEMOGRAPHY_CORRECTION = age_distribution("Brazil", 2020, coarse=True) / age_distribution( "Brazil", 2010, coarse=True ) class Input: def __init__(self, country, display_country=None, target=None): self.country = country self.display_country = display_country or country.title() self.target = target or st.sidebar def run(self): """ Return a dictionary of keyword arguments from user input. This dictionary can be passed to the model constructor with minimal