Skip to content

Commit 92951cf

Browse files
committed
Added TableIndexError
1 parent c44d071 commit 92951cf

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

activitysim/core/exceptions.py

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

80+
8081
class SubprocessError(RuntimeError):
8182
"""An error occurred in a subprocess."""
8283

84+
8385
class SegmentedSpecificationError(RuntimeError):
84-
"""An error was caused by creating an invalid spec table for a segmented model component."""
86+
"""An error was caused by creating an invalid spec table for a segmented model component."""
87+
88+
89+
class TableIndexError(RuntimeError):
90+
"""An error related to the index of a table in the pipeline."""

activitysim/core/logit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from activitysim.core import tracing, workflow
1212
from activitysim.core.choosing import choice_maker
1313
from activitysim.core.configuration.logit import LogitNestSpec
14-
from activitysim.core.exceptions import InvalidTravelError, ModelConfigurationError
14+
from activitysim.core.exceptions import InvalidTravelError, ModelConfigurationError, TableIndexError
1515

1616
logger = logging.getLogger(__name__)
1717

@@ -361,11 +361,11 @@ def interaction_dataset(
361361
362362
"""
363363
if not choosers.index.is_unique:
364-
raise RuntimeError(
364+
raise TableIndexError(
365365
"ERROR: choosers index is not unique, " "sample will not work correctly"
366366
)
367367
if not alternatives.index.is_unique:
368-
raise RuntimeError(
368+
raise TableIndexError(
369369
"ERROR: alternatives index is not unique, " "sample will not work correctly"
370370
)
371371

activitysim/core/random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pandas as pd
1111

1212
from activitysim.core.util import reindex
13-
from activitysim.core.exceptions import DuplicateLoadableObjectError
13+
from activitysim.core.exceptions import DuplicateLoadableObjectError, TableIndexError
1414

1515
from .tracing import print_elapsed_time
1616

@@ -396,7 +396,7 @@ def get_channel_for_df(self, df):
396396

397397
channel_name = self.index_to_channel.get(df.index.name, None)
398398
if channel_name is None:
399-
raise RuntimeError("No channel with index name '%s'" % df.index.name)
399+
raise TableIndexError("No channel with index name '%s'" % df.index.name)
400400
return self.channels[channel_name]
401401

402402
# step handling

activitysim/core/skim_dictionary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pandas as pd
1111

1212
from activitysim.core import workflow
13-
from activitysim.core.exceptions import StateAccessError
13+
from activitysim.core.exceptions import StateAccessError, TableIndexError
1414

1515
logger = logging.getLogger(__name__)
1616

@@ -907,7 +907,7 @@ def get(self, row_ids, col_ids):
907907
not_in_skim = not_in_skim.values
908908
logger.warning(f"row_ids: {row_ids[not_in_skim]}")
909909
logger.warning(f"col_ids: {col_ids[not_in_skim]}")
910-
raise RuntimeError(
910+
raise TableIndexError(
911911
f"DataFrameMatrix: {not_in_skim.sum()} row_ids of {len(row_ids)} not in skim."
912912
)
913913

0 commit comments

Comments
 (0)