Skip to content

Commit

Permalink
Merge branch 'cfg-doc-2' into cfg-documentation-vy
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Sep 19, 2023
2 parents 3c45b16 + 4657ec3 commit fbcc9a1
Show file tree
Hide file tree
Showing 43 changed files with 171 additions and 171 deletions.
2 changes: 1 addition & 1 deletion activitysim/abm/models/auto_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger = logging.getLogger(__name__)


class AutoOwnershipSettings(PydanticReadable):
class AutoOwnershipSettings(LogitComponentSettings):
"""
Settings for the `auto_ownership` component.
"""
Expand Down
3 changes: 0 additions & 3 deletions activitysim/abm/models/location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ def _location_sample(

sample_size = model_settings.SAMPLE_SIZE

if "sched" in trace_label:
print()

if state.settings.disable_destination_sampling or (
estimator and estimator.want_unsampled_alternatives
):
Expand Down
2 changes: 1 addition & 1 deletion activitysim/abm/models/parking_location_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def parking_location(
proposed_trip_departure_period = model_settings["TRIP_DEPARTURE_PERIOD"]
# TODO: the number of skim time periods should be more readily available than this
n_skim_time_periods = np.unique(
network_los.los_settings.skim_time_periods["labels"]
network_los.los_settings.skim_time_periods.labels
).size
if trips_merged_df[proposed_trip_departure_period].max() > n_skim_time_periods:
# max proposed_trip_departure_period is out of range,
Expand Down
12 changes: 5 additions & 7 deletions activitysim/abm/models/tour_od_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ def tour_od_choice(
Parameters
----------
tours : orca.DataFrameWrapper
tours : pd.DataFrame
lazy-loaded tours table
persons : orca.DataFrameWrapper
persons : pd.DataFrame
lazy-loaded persons table
households : orca.DataFrameWrapper
households : pd.DataFrame
lazy-loaded households table
land_use : orca.DataFrameWrapper
land_use : pd.DataFrame
lazy-loaded land use data table
stop_frequency_alts : orca.DataFrameWrapper
lazy-loaded table of stop frequency alternatives, e.g. "1out2in"
network_los : orca._InjectableFuncWrapper
network_los : los.Network_LOS
lazy-loaded activitysim.los.Network_LOS object
"""
if model_settings is None:
Expand Down
6 changes: 6 additions & 0 deletions activitysim/abm/models/trip_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def DESTINATION_SPEC(self) -> Path:
return self.SPEC


@workflow.func
def _destination_sample(
state: workflow.State,
primary_purpose,
Expand Down Expand Up @@ -218,6 +219,7 @@ def _destination_sample(
return choices


@workflow.func
def destination_sample(
state: workflow.State,
primary_purpose,
Expand Down Expand Up @@ -521,6 +523,7 @@ def choose_MAZ_for_TAZ(
return taz_choices


@workflow.func
def destination_presample(
state: workflow.State,
primary_purpose,
Expand Down Expand Up @@ -669,6 +672,7 @@ def trip_destination_sample(
return choices


@workflow.func
def compute_ood_logsums(
state: workflow.State,
choosers,
Expand Down Expand Up @@ -960,6 +964,7 @@ def trip_destination_simulate(
return destinations


@workflow.func
def choose_trip_destination(
state: workflow.State,
primary_purpose,
Expand Down Expand Up @@ -1184,6 +1189,7 @@ def logsum_skims(self):
return skims


@workflow.func
def run_trip_destination(
state: workflow.State,
trips: pd.DataFrame,
Expand Down
2 changes: 1 addition & 1 deletion activitysim/abm/models/trip_mode_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def trip_mode_choice(

orig_col = "origin"
dest_col = "destination"
min_per_period = network_los.skim_time_periods["period_minutes"]
min_per_period = network_los.skim_time_periods.period_minutes
periods_per_hour = 60 / min_per_period

constants = {}
Expand Down
3 changes: 2 additions & 1 deletion activitysim/abm/models/util/annotate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# ActivitySim
# See full license in LICENSE.txt.

from __future__ import annotations

import logging

import pandas as pd

from activitysim.core import expressions, tracing, workflow
from activitysim.core.configuration import PydanticBase

Expand Down
1 change: 1 addition & 0 deletions activitysim/abm/models/util/tour_od.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import logging
from typing import Optional

import numpy as np
import pandas as pd
Expand Down
13 changes: 6 additions & 7 deletions activitysim/abm/models/vehicle_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ def vehicle_allocation(
Parameters
----------
state : workflow.State
persons : orca.DataFrameWrapper
households : orca.DataFrameWrapper
vehicles : orca.DataFrameWrapper
vehicles_merged : orca.DataFrameWrapper
tours : orca.DataFrameWrapper
tours_merged : orca.DataFrameWrapper
chunk_size : orca.injectable
persons : pd.DataFrame
households : pd.DataFrame
vehicles : pd.DataFrame
tours : pd.DataFrame
tours_merged : pd.DataFrame
network_los : los.Network_LOS
"""
trace_label = "vehicle_allocation"
model_settings_file_name = "vehicle_allocation.yaml"
Expand Down
8 changes: 4 additions & 4 deletions activitysim/abm/models/vehicle_type_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def iterate_vehicle_type_choice(
locals_dict : dict
additional variables available when writing expressions
estimator : Estimator object
chunk_size : orca.injectable
chunk_size : int
trace_label : str
Returns
Expand Down Expand Up @@ -516,9 +516,9 @@ def vehicle_type_choice(
Parameters
----------
persons : orca.DataFrameWrapper
households : orca.DataFrameWrapper
vehicles : orca.DataFrameWrapper
persons : pd.DataFrame
households : pd.DataFrame
vehicles : pd.DataFrame
vehicles_merged : DataFrame
"""
trace_label = "vehicle_type_choice"
Expand Down
2 changes: 2 additions & 0 deletions activitysim/abm/tables/landuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from activitysim.core import workflow
from activitysim.core.exceptions import MissingInputTableDefinition
from activitysim.core.input import read_input_table
from activitysim.core.los import Network_LOS
from activitysim.core.skim_dictionary import SkimDict

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion activitysim/abm/tables/shadow_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def __init__(
self.target[segment] = land_use[target]

def read_saved_shadow_prices(
self, state, model_settings: TourLocationComponentSettings
self, state: workflow.State, model_settings: TourLocationComponentSettings
):
"""
Read saved shadow_prices from csv file in data_dir (so-called warm start)
Expand Down
2 changes: 1 addition & 1 deletion activitysim/benchmarking/componentwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def run_component(state, component_name):
def teardown_component(state, component_name):
logger.info("teardown_component: %s", component_name)

# use the pipeline module to clear out all the orca tables, so
# use the pipeline module to clear out all the tables, so
# the next benchmark run has a clean slate.
# anything needed should be reloaded from the pipeline checkpoint file
pipeline_tables = state.registered_tables()
Expand Down
3 changes: 2 additions & 1 deletion activitysim/cli/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import json
import os
import shutil
Expand Down Expand Up @@ -43,7 +45,6 @@
"pyyaml": [],
"pytables": [],
"toolz": [],
"orca": [],
"psutil": [],
"requests": [],
"numba": ["0.54"],
Expand Down
12 changes: 7 additions & 5 deletions activitysim/core/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# ActivitySim
# See full license in LICENSE.txt.

from __future__ import annotations

import logging
Expand All @@ -11,6 +8,10 @@
from activitysim.core.configuration.base import PydanticBase
from activitysim.core.configuration.logit import LogitComponentSettings

# ActivitySim
# See full license in LICENSE.txt.


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -177,10 +178,11 @@ def filter_warnings(state=None):

# beginning pandas version 1.3, various places emit a PerformanceWarning that is
# caught in the "strict" filter above, but which are currently unavoidable for complex models.
# These warning are left as warnings as an invitation for future enhancement.
# Turning this filter back to "default" could be a good helper for finding places to
# look for future performance enhancements.
from pandas.errors import PerformanceWarning

warnings.filterwarnings("default", category=PerformanceWarning)
warnings.filterwarnings("ignore", category=PerformanceWarning)

# pandas 1.5
# beginning in pandas version 1.5, a new warning is emitted when a column is set via iloc
Expand Down
51 changes: 43 additions & 8 deletions activitysim/core/configuration/network.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from __future__ import annotations

import warnings
from pathlib import Path
from typing import Literal

from pydantic import PositiveInt, root_validator

from activitysim.core.configuration.base import (
Any,
PydanticBase,
Expand Down Expand Up @@ -156,6 +159,44 @@ class MazToMazSettings(PydanticBase, extra="forbid"):
"""The name of the skim table used to blend distances for MAZs."""


class TimeSettings(PydanticReadable, extra="forbid"):
"""
Settings to describe discrete time.
"""

time_window: PositiveInt = 1440
"""total duration (in minutes) of the modeled time span."""

period_minutes: PositiveInt = 60
"""length of time (in minutes) each model time period represents.
Must be whole factor of ``time_window``."""

periods: list[int]
"""Breakpoints that define the aggregate periods for skims and assignment.
The first value should be zero and the last value should equal `time_window`
divided by `period_minutes`. The intervals between these various values
represent the skimmed time periods, so this list should be one longer than
that of `labels`.
"""

labels: list[str]
"""Labels to define names for aggregate periods for skims and assignment"""

@root_validator(pre=True)
def hours_deprecated(cls, data):
if "hours" in data:
data["periods"] = data.pop("hours")
warnings.warn(
"support for `skim_time_periods` key `hours` will be removed in "
"future verions. Use `periods` instead",
FutureWarning,
stacklevel=2,
)
return data


class NetworkSettings(PydanticReadable, extra="forbid"):
"""
Network level of service and skims settings
Expand Down Expand Up @@ -188,14 +229,8 @@ class NetworkSettings(PydanticReadable, extra="forbid"):
TAZ_Settings class, which allows for ZARR transformation and pre-processing.
"""

skim_time_periods: dict
"""time period upper bound values and labels
* ``time_window`` - total duration (in minutes) of the modeled time span (Default: 1440 minutes (24 hours))
* ``period_minutes`` - length of time (in minutes) each model time period represents. Must be whole factor of ``time_window``. (Default: 60 minutes)
* ``periods`` - Breakpoints that define the aggregate periods for skims and assignment
* ``labels`` - Labels to define names for aggregate periods for skims and assignment
"""
skim_time_periods: TimeSettings
"""How to discretize time in this model."""

read_skim_cache: bool = False
"""Read cached skims (using numpy memmap) from output directory.
Expand Down
9 changes: 2 additions & 7 deletions activitysim/core/configuration/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,21 +620,16 @@ class Settings(PydanticBase, extra="allow", validate_assignment=True):
rng_base_seed: Union[int, None] = 0
"""Base seed for pseudo-random number generator."""

duplicate_step_execution: Literal["raise", "warn", "allow"] = "raise"
duplicate_step_execution: Literal["error", "allow"] = "error"
"""
How activitysim should handle attempts to re-run a step with the same name.
.. versionadded:: 1.3
* "raise"
* "error"
Attempts to re-run a step that has already been run and
checkpointed will raise a `RuntimeError`, halting model execution.
This is the default if no value is given.
* "warn"
Attempts to re-run a step that has already been run and
checkpointed will be trigger a warning message and that particular step
will not be (re)executed, but overall model execution will be allowed to
continue.
* "allow"
Attempts to re-run a step are allowed, potentially overwriting
the results from the previous time that step was run.
Expand Down
Loading

0 comments on commit fbcc9a1

Please sign in to comment.