Ejemplo n.º 1
0
def test_stratify_compartments__with_no_extisting_strat_and_subset_only():
    strat = Stratification(
        name="age",
        strata=["0", "10", "20"],
        compartments=["S"],
    )
    comps = [Compartment("S"), Compartment("I"), Compartment("R")]
    strat_comps = strat._stratify_compartments(comps)
    assert strat_comps == [
        Compartment("S", {"age": "0"}),
        Compartment("S", {"age": "10"}),
        Compartment("S", {"age": "20"}),
        Compartment("I"),
        Compartment("R"),
    ]
Ejemplo n.º 2
0
def test_stratify_compartments__with_extisting_strat():
    age_strat = Stratification(
        name="age",
        strata=["0", "10", "20"],
        compartments=["S", "I", "R"],
    )
    comps = [Compartment("S"), Compartment("I"), Compartment("R")]
    age_comps = age_strat._stratify_compartments(comps)
    loc_strat = Stratification(
        name="location",
        strata=["rural", "urban"],
        compartments=["S", "I", "R"],
    )
    loc_comps = loc_strat._stratify_compartments(age_comps)
    assert loc_comps == [
        Compartment("S", {
            "age": "0",
            "location": "rural"
        }),
        Compartment("S", {
            "age": "0",
            "location": "urban"
        }),
        Compartment("S", {
            "age": "10",
            "location": "rural"
        }),
        Compartment("S", {
            "age": "10",
            "location": "urban"
        }),
        Compartment("S", {
            "age": "20",
            "location": "rural"
        }),
        Compartment("S", {
            "age": "20",
            "location": "urban"
        }),
        Compartment("I", {
            "age": "0",
            "location": "rural"
        }),
        Compartment("I", {
            "age": "0",
            "location": "urban"
        }),
        Compartment("I", {
            "age": "10",
            "location": "rural"
        }),
        Compartment("I", {
            "age": "10",
            "location": "urban"
        }),
        Compartment("I", {
            "age": "20",
            "location": "rural"
        }),
        Compartment("I", {
            "age": "20",
            "location": "urban"
        }),
        Compartment("R", {
            "age": "0",
            "location": "rural"
        }),
        Compartment("R", {
            "age": "0",
            "location": "urban"
        }),
        Compartment("R", {
            "age": "10",
            "location": "rural"
        }),
        Compartment("R", {
            "age": "10",
            "location": "urban"
        }),
        Compartment("R", {
            "age": "20",
            "location": "rural"
        }),
        Compartment("R", {
            "age": "20",
            "location": "urban"
        }),
    ]