Skip to content

Commit

Permalink
Merge pull request #819 from wsp-sag/time-period-cat-legacy-mode
Browse files Browse the repository at this point in the history
Time period to categorical in legacy mode
  • Loading branch information
jpn-- authored Feb 27, 2024
2 parents 3060911 + dddf34f commit 64cacd2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions activitysim/core/skim_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ActivitySim
# See full license in LICENSE.txt.
from __future__ import annotations
from collections import OrderedDict

import logging
from builtins import object, range
Expand All @@ -9,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 @@ -165,6 +167,20 @@ def __init__(self, state, skim_tag, skim_info, skim_data):
self.skim_info = skim_info
self.usage = set() # track keys of skims looked up

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
) # (in function so subclass can override)
Expand Down

0 comments on commit 64cacd2

Please sign in to comment.