Skip to content

Commit

Permalink
fail protection for existing unit tests that do not initialize state.…
Browse files Browse the repository at this point in the history
…network_settings
  • Loading branch information
i-am-sijia committed Feb 27, 2024
1 parent c94016d commit 88043d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions activitysim/core/skim_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pandas as pd

from activitysim.core import workflow
from activitysim.core.exceptions import StateAccessError

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -166,10 +167,13 @@ def __init__(self, state, skim_tag, skim_info, skim_data):
self.skim_info = skim_info
self.usage = set() # track keys of skims looked up

self.time_label_dtype = pd.api.types.CategoricalDtype(
list(OrderedDict.fromkeys(state.network_settings.skim_time_periods.labels)),
ordered=True,
)
try:
self.time_label_dtype = pd.api.types.CategoricalDtype(
list(OrderedDict.fromkeys(state.network_settings.skim_time_periods.labels)),
ordered=True,
)
except StateAccessError:
logger.info(f"Cannot access state.network_settings.skim_time_periods.labels. SkimDict.time_label_dtype is not set")

self.offset_mapper = self._offset_mapper(
state
Expand Down

0 comments on commit 88043d4

Please sign in to comment.