From 684c9d9937c176cdda364885fbec580f8789fe6e Mon Sep 17 00:00:00 2001 From: Sijia Wang Date: Tue, 30 Jul 2024 11:13:28 -0400 Subject: [PATCH] blacken --- .../network/transit/transit_network.py | 14 ++++----- tm2py/config.py | 30 +++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tm2py/components/network/transit/transit_network.py b/tm2py/components/network/transit/transit_network.py index 4473b43c..949a4272 100644 --- a/tm2py/components/network/transit/transit_network.py +++ b/tm2py/components/network/transit/transit_network.py @@ -792,7 +792,7 @@ def run(self): if self.config.journey_levels.use_algorithm == True: faresystem_groups = self.group_faresystems(faresystems) - if self.config.journey_levels.specify_manually ==True: + if self.config.journey_levels.specify_manually == True: faresystem_groups = self.group_faresystems_simplified(faresystems) journey_levels, mode_map = self.generate_transfer_fares( @@ -1507,14 +1507,14 @@ def matching_xfer_fares(xfer_fares_list1, xfer_fares_list2): self._log.append({"content": xfer_fares_table, "type": "table"}) return faresystem_groups - + def group_faresystems_simplified(self, faresystems): """This function allows for manual specification of journey levels/ faresystem groups""" - self._log.append( - {"type": "header", "content": "Simplified faresystem groups"} - ) + self._log.append({"type": "header", "content": "Simplified faresystem groups"}) - manual_groups = [groups.group_fare_systems for groups in self.config.journey_levels.manual] + manual_groups = [ + groups.group_fare_systems for groups in self.config.journey_levels.manual + ] group_xfer_fares_mode = [([], [], []) for _ in range(len(manual_groups) + 1)] for fs_id, fs_data in faresystems.items(): @@ -1527,7 +1527,7 @@ def group_faresystems_simplified(self, faresystems): group_xfer_fares_mode[i][1].append(fs_id) group_xfer_fares_mode[i][2].extend(fs_modes) assigned = True - break + break if not assigned: group_xfer_fares_mode[-1][0].append(xfers) group_xfer_fares_mode[-1][1].append(fs_id) diff --git a/tm2py/config.py b/tm2py/config.py index fa744a2b..96efb6e5 100644 --- a/tm2py/config.py +++ b/tm2py/config.py @@ -1143,6 +1143,7 @@ class TransitVehicleConfig(ConfigItem): @dataclass(frozen=True) class TransitClassConfig(ConfigItem): """Transit demand class definition.""" + skim_set_id: str name: str description: str @@ -1153,14 +1154,16 @@ class TransitClassConfig(ConfigItem): @dataclass(frozen=True) class ManualJourneyLevelsConfig(ConfigItem): - """Manual Journey Level Specification""" - level_id: int - group_fare_systems: Tuple[int, ...] + """Manual Journey Level Specification""" + + level_id: int + group_fare_systems: Tuple[int, ...] @dataclass(frozen=True) class TransitJourneyLevelsConfig(ConfigItem): """Transit manual journey levels structure.""" + use_algorithm: bool = False """ The original translation from Cube to Emme used an algorithm to, as faithfully as possible, reflect transfer fares via journey levels. @@ -1177,8 +1180,10 @@ class TransitJourneyLevelsConfig(ConfigItem): To specify this configuration, a single `manual` entry identifying the SF Muni fare systems is needed. The other faresystem group is automatically generated in the code with the rest of the faresystems which are not specified in any of the groups. See the `manual` entry for an example. - """ - manual: Optional[Tuple[ManualJourneyLevelsConfig, ...]] = (ManualJourneyLevelsConfig(level_id=1, group_fare_systems=(25,)),) + """ + manual: Optional[Tuple[ManualJourneyLevelsConfig, ...]] = ( + ManualJourneyLevelsConfig(level_id=1, group_fare_systems=(25,)), + ) """ If 'specify_manually' is set to `True`, there should be at least one faresystem group specified here. The format includes two entries: `level_id`, which is the serial number of the group specified, @@ -1197,23 +1202,25 @@ class TransitJourneyLevelsConfig(ConfigItem): group_fare_systems = [12,14] """ - @validator("specify_manually") def check_exclusivity(cls, v, values): """Valdiates that exactly one of specify_manually and use_algorithm is True""" use_algorithm = values.get("use_algorithm") - assert (use_algorithm != v), 'Exactly one of "use_algorithm" or "specify_manually" must be True.' + assert ( + use_algorithm != v + ), 'Exactly one of "use_algorithm" or "specify_manually" must be True.' return v - @validator('manual', always=True) + @validator("manual", always=True) def check_manual(cls, v, values): - if values.get('specify_manually'): - assert v is not None and len(v) > 0, "If 'specify_manually' is True, 'manual' cannot be None or empty." + if values.get("specify_manually"): + assert ( + v is not None and len(v) > 0 + ), "If 'specify_manually' is True, 'manual' cannot be None or empty." return v - @dataclass(frozen=True) class AssignmentStoppingCriteriaConfig(ConfigItem): "Assignment stop configuration parameters." @@ -1266,7 +1273,6 @@ class CongestedAssnConfig(ConfigItem): pm_peaking_factor: float = Field(default=1.262) - @dataclass(frozen=True) class TransitConfig(ConfigItem): """Transit assignment parameters."""