Skip to content

Commit c44d071

Browse files
committed
Created SegmentedSpecificationError for when there's an issue with a spec table that's created for a specific segment
1 parent a9d57a2 commit c44d071

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

activitysim/abm/models/trip_departure_choice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from activitysim.core.skim_dataset import SkimDataset
2828
from activitysim.core.skim_dictionary import SkimDict
2929
from activitysim.core.util import reindex
30+
from activitysim.core.exceptions import SegmentedSpecificationError
3031

3132
logger = logging.getLogger(__name__)
3233

@@ -219,7 +220,7 @@ def choose_tour_leg_pattern(
219220
)
220221

221222
if len(spec.columns) > 1:
222-
raise RuntimeError("spec must have only one column")
223+
raise SegmentedSpecificationError("spec must have only one column")
223224

224225
# - join choosers and alts
225226
# in vanilla interaction_simulate interaction_df is cross join of choosers and alternatives

activitysim/core/exceptions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@ class InputPopulationError(RuntimeError):
7878
"""An issue with the input population was found."""
7979

8080
class SubprocessError(RuntimeError):
81-
"""An error occurred in a subprocess."""
81+
"""An error occurred in a subprocess."""
82+
83+
class SegmentedSpecificationError(RuntimeError):
84+
"""An error was caused by creating an invalid spec table for a segmented model component."""

activitysim/core/interaction_sample.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from activitysim.core.configuration.base import ComputeSettings
2121
from activitysim.core.skim_dataset import DatasetWrapper
2222
from activitysim.core.skim_dictionary import SkimWrapper
23+
from activitysim.core.exceptions import SegmentedSpecificationError
2324

2425
logger = logging.getLogger(__name__)
2526

@@ -219,7 +220,7 @@ def _interaction_sample(
219220
)
220221

221222
if len(spec.columns) > 1:
222-
raise RuntimeError("spec must have only one column")
223+
raise SegmentedSpecificationError("spec must have only one column")
223224

224225
# if using skims, copy index into the dataframe, so it will be
225226
# available as the "destination" for set_skim_wrapper_targets

activitysim/core/interaction_sample_simulate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from activitysim.core import chunk, interaction_simulate, logit, tracing, util, workflow
1111
from activitysim.core.configuration.base import ComputeSettings
1212
from activitysim.core.simulate import set_skim_wrapper_targets
13+
from activitysim.core.exceptions import SegmentedSpecificationError
1314

1415
logger = logging.getLogger(__name__)
1516

@@ -115,7 +116,7 @@ def _interaction_sample_simulate(
115116
)
116117

117118
if len(spec.columns) > 1:
118-
raise RuntimeError("spec must have only one column")
119+
raise SegmentedSpecificationError("spec must have only one column")
119120

120121
# if using skims, copy index into the dataframe, so it will be
121122
# available as the "destination" for the skims dereference below

activitysim/core/interaction_simulate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from activitysim.core import chunk, logit, simulate, timing, tracing, util, workflow
1717
from activitysim.core.configuration.base import ComputeSettings
1818
from activitysim.core.fast_eval import fast_eval
19+
from activitysim.core.exceptions import SegmentedSpecificationError
1920

2021
logger = logging.getLogger(__name__)
2122

@@ -722,7 +723,7 @@ def _interaction_simulate(
722723
)
723724

724725
if len(spec.columns) > 1:
725-
raise RuntimeError("spec must have only one column")
726+
raise SegmentedSpecificationError("spec must have only one column")
726727

727728
sample_size = sample_size or len(alternatives)
728729

0 commit comments

Comments
 (0)