예제 #1
0
 def _assign_work_location(self, i: int, person: Person,
                           wf_area_df: pd.DataFrame):
     """
     Employ people in any given sector.
     """
     if person.sex == "f":
         work_location = wf_area_df.index.values[
             self.work_msoa_woman_rnd[i]]
     else:
         work_location = wf_area_df.index.values[self.work_msoa_man_rnd[i]]
     try:
         super_area = self.super_areas.members_by_name[work_location]
         super_area.add_worker(person)
     except KeyError:
         if work_location in list(self.non_geographical_work_location):
             if self.non_geographical_work_location[
                     work_location] == "home":
                 person.work_super_area = None
             elif self.non_geographical_work_location[
                     work_location] == "bind":
                 self._select_rnd_superarea(person)
             else:
                 raise KeyError(
                     f"Work location {work_location} not found in world's geogeraphy"
                 )
         else:
             self._select_rnd_superarea(person)
예제 #2
0
 def _assign_work_location(self, i: int, person: Person, wf_area_df: pd.DataFrame):
     """
     Employ people in any given sector.
     """
     if person.sex == "f":
         work_location = wf_area_df.index.values[self.work_msoa_woman_rnd[i]]
     else:
         work_location = wf_area_df.index.values[self.work_msoa_man_rnd[i]]
     super_area = [
         super_area
         for super_area in self.super_areas
         if super_area.name == work_location
     ]
     if super_area:
         super_area = super_area[0]
         super_area.add_worker(person)
     elif work_location in list(self.non_geographical_work_location.keys()):
         if self.non_geographical_work_location[work_location] == "home":
             person.work_super_area = "home"
         elif self.non_geographical_work_location[work_location] == "bind":
             self._select_rnd_superarea(person)
         else:
             raise ValueError
     else:
         self._select_rnd_superarea(person)