def test_variableset(): v1 = VariableSet() v2 = VariableSet() assert len(v1) == 0 assert len(v2) == 0 with pytest.raises(KeyError): v1["beta[1]"] v1["beta[1]"] = 0.5 assert v1["beta[1]"] == 0.5 assert len(v1) == 1 assert v1 != v2 v2["beta[1]"] = 0.5 assert v1 == v2 d = Disease.load("ncov") p = Parameters() p.set_disease("ncov") assert p.disease_params == d assert p.disease_params.beta[1] != 0.5 p = p.set_variables(v1) assert p.disease_params.beta[1] == 0.5
def test_set_variables(): d = Disease.load("ncov") p = Parameters() p.set_disease("ncov") assert p.disease_params == d variables = VariableSet(l1) p2 = p.set_variables(variables) assert p.disease_params == d assert p2.disease_params != d assert p2.disease_params.beta[2] == 0.9 assert p2.disease_params.beta[3] == 0.93 assert p2.disease_params.progress[1] == 0.18 assert p2.disease_params.progress[2] == 0.92 assert p2.disease_params.progress[3] == 0.90 variables = VariableSet(l0) p3 = p2.set_variables(variables) assert p3.disease_params.beta[2] == 0.95 assert p3.disease_params.beta[3] == 0.95 assert p3.disease_params.progress[1] == 0.19 assert p3.disease_params.progress[2] == 0.91 assert p3.disease_params.progress[3] == 0.91