From 88043d4c4e90bfe4a0197fd2ab6f75656e2fb2f2 Mon Sep 17 00:00:00 2001 From: Sijia Wang Date: Tue, 27 Feb 2024 11:29:39 -0500 Subject: [PATCH] fail protection for existing unit tests that do not initialize state.network_settings --- activitysim/core/skim_dictionary.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/activitysim/core/skim_dictionary.py b/activitysim/core/skim_dictionary.py index 6d805d352..7494e11fe 100644 --- a/activitysim/core/skim_dictionary.py +++ b/activitysim/core/skim_dictionary.py @@ -10,6 +10,7 @@ import pandas as pd from activitysim.core import workflow +from activitysim.core.exceptions import StateAccessError logger = logging.getLogger(__name__) @@ -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