def test_apply_person_based_full_quarantine(population): policy = policies.HouseholdQuarantined( probability_samplers.PersonProbability(1)) policies.apply_policies(population, policy, in_place=True) for hid, household in population.households.items(): for pid, person in household.people.items(): assert_single_home_activity(person)
def test_apply_two_policies(population): policy1 = policies.HouseholdQuarantined(.1) policy2 = policies.PersonStayAtHome(.4) counter = 0 policies.apply_policies(population, [policy1, policy2], in_place=True) for hid, household in population.households.items(): assert len(household.people) == 2 for pid, person in household.people.items(): counter += len(person.plan) == 1 assert counter < 60 # super dodgy test with probability
def test_plot_population_comparisons(Steve, Hilda): population_1 = Population() for i, person in enumerate([Steve, Hilda]): hh = Household(i) hh.add(person) population_1.add(hh) population_1.name = 'base' population_2 = deepcopy(population_1) population_2.name = 'work_removed' policy_remove_work = policies.RemovePersonActivities(activities=['work'], probability=1) policies.apply_policies(population_2, [policy_remove_work]) list_of_populations = [population_1, population_2] outputs = plot_population_comparisons(list_of_populations, 'home') legs = outputs[2] activities = outputs[3] check = calculate_leg_duration_by_mode(population_2) assert isinstance(outputs[0], Figure) assert isinstance(outputs[1], Figure) assert legs.loc['work_removed', 'walk'] == check.loc[check['leg mode'] == 'walk', 'duration_hours'].iloc[0]
def test_apply_full_person_stay_at_home(population): policy = policies.PersonStayAtHome(1) policies.apply_policies(population, policy, in_place=True) for hid, household in population.households.items(): for pid, person in household.people.items(): assert_single_home_activity(person)
def test_apply_full_hh_quarantine(population): policy = policies.HouseholdQuarantined(1) policies.apply_policies(population, policy, in_place=True) for hid, household in population.households.items(): for pid, person in household.people.items(): assert_single_home_activity(person)
def test_apply_person_based_full_hh_quarantine_doesnt_create_or_delete_households( population): policy = policies.HouseholdQuarantined( probability_samplers.PersonProbability(1)) policies.apply_policies(population, policy, in_place=True) assert len(population.households) == 20
def test_apply_full_hh_quarantine_doesnt_create_or_delete_households( population): policy = policies.HouseholdQuarantined(1) policies.apply_policies(population, policy, in_place=True) assert len(population.households) == 20