Exemplo n.º 1
0
    def test__symptoms_progression(self):
        selector = infect.InfectionSelector.from_file(transmission_config_path=paths.configs_path / 'defaults/transmission/TransmissionConstant.yaml')
        dummy = Person(sex='f', age=65)
        infection = selector.make_infection(person=dummy, time=0.1)
        fixed_severity = 0.97
        infection.symptoms.max_severity = fixed_severity
        max_tag = infection.symptoms.max_tag()
        assert max_tag == june.infection.symptom_tag.SymptomTag.hospitalised
        infection.symptoms.trajectory = selector.trajectory_maker[max_tag]
        print(infection.symptoms.trajectory)
        assert infection.symptoms.trajectory == [
            (0.0, june.infection.symptom_tag.SymptomTag.exposed),
            (pytest.approx(5, 2.5), june.infection.symptom_tag.SymptomTag.mild),
            (pytest.approx(5, rel=5), june.infection.symptom_tag.SymptomTag.hospitalised),
            (pytest.approx(13, rel=5), june.infection.symptom_tag.SymptomTag.mild),
            (pytest.approx(30, rel=5), june.infection.symptom_tag.SymptomTag.recovered),
        ]
        hospitalised_time = infection.symptoms.trajectory[2][0]

        infection.update_at_time(float(1.))
        assert infection.symptoms.tag == june.infection.symptom_tag.SymptomTag.exposed
        infection.update_at_time(float(1.))
        assert infection.symptoms.tag == june.infection.symptom_tag.SymptomTag.exposed
        infection.update_at_time(float(6.))
        assert infection.symptoms.tag == june.infection.symptom_tag.SymptomTag.mild
        infection.update_at_time(hospitalised_time + 8.)
        assert infection.symptoms.tag == june.infection.symptom_tag.SymptomTag.hospitalised
        infection.update_at_time(float(40.))
        assert infection.symptoms.tag == june.infection.symptom_tag.SymptomTag.mild
        infection.update_at_time(float(50.))
        assert infection.symptoms.tag == june.infection.symptom_tag.SymptomTag.recovered
Exemplo n.º 2
0
    def missing_workforce_nr(self):
        """
        Estimate missing workforce in simulated region.
        This will establish the number of workers recruited
        from the boundary.
        """

        self.ADULT_THRESHOLD = self.world.config["people"]["adult_threshold"]
        self.OLD_THRESHOLD = self.world.config["people"]["old_threshold"]
        self._init_frequencies()

        for company in self.world.companies.members:
            # nr. of missing workforce
            # TODO companies shouldn always be completely full
            n_residents = (company.n_employees_max - company.n_employees)

            (sex_rnd_arr, nomis_bin_rnd_arr,
             age_rnd_arr) = self.init_random_variables(n_residents,
                                                       company.industry)

            for i in range(n_residents):
                # create new person
                person = Person(
                    self.world,
                    (i + self.n_residents),
                    'boundary',
                    company.msoa,
                    age_rnd_arr[i],
                    nomis_bin_rnd_arr[i],
                    sex_rnd_arr[i],
                    econ_index=0,
                    mode_of_transport=None,
                )
                person.industry = company.industry

                # Inform groups about new person
                self.people.append(person)
                self.world.people.members.append(person)
                company.people.append(person)
                idx = [
                    idx for idx, msoa in enumerate(self.world.msoareas.members)
                    if msoa.name == company.msoa
                ][0]
                self.world.msoareas.members[idx].work_people.append(person)

            self.n_residents += n_residents
Exemplo n.º 3
0
 def test_group_types(self):
     group = Household()
     group.add(Person(), Household.SubgroupType.adults)
     assert group[Household.SubgroupType.adults].size == 1