Skip to content

Commit

Permalink
validation
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-sijia committed Jul 9, 2024
1 parent 809627e commit d479415
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tm2py/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,14 +1350,14 @@ def maz_skim_period_exists(cls, value, values):
), "maz_to_maz -> skim_period -> name not found in time_periods list"
return value

@validator("highway")
@validator("highway", always=True)
def relative_gap_length(cls, value, values):
"""Validate highway.relative_gaps is a list of the same length as global iterations."""
if "end_iteration" in values:
assert (
len(value.relative_gaps) == len(values["end_iteration"]+1),
"relative_gap must be the same length as end_iteration+1",
)
if "run" in values:
assert len(value.relative_gaps) == (
values["run"]["end_iteration"] + 1
), f"'highway.relative_gaps must be the same length as end_iteration+1,\
that includes global iteration 0 to {values['run']['end_iteration']}'"
return value


Expand Down

0 comments on commit d479415

Please sign in to comment.