Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions activitysim/abm/models/non_mandatory_tour_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import logging
import warnings
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -200,12 +201,24 @@ def non_mandatory_tour_frequency(
model_settings_file_name,
)

# FIXME kind of tacky both that we know to add this here and del it below
# 'tot_tours' is used in model_spec expressions
alternatives = simulate.read_model_alts(
state, "non_mandatory_tour_frequency_alternatives.csv", set_index=None
)
alternatives["tot_tours"] = alternatives.sum(axis=1)
if "tot_tours" not in alternatives.columns:
# add a column for total tours
alternatives["tot_tours"] = alternatives.sum(axis=1)
warnings.warn(
"The 'tot_tours' column may not be automatically added in the future.",
FutureWarning,
)
else:
# tot_tours already exists, check if it is consistent with legacy behavior
if not (alternatives["tot_tours"] == alternatives.sum(axis=1)).all():
warnings.warn(
"The 'tot_tours' column in non_mandatory_tour_frequency_alternatives.csv "
"does not match the sum of the other columns.",
RuntimeWarning,
)

# filter based on results of CDAP
choosers = persons_merged
Expand Down
2 changes: 1 addition & 1 deletion activitysim/abm/models/util/canonical_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def determine_flavors_from_alts_file(
flavors = {
c: int(alts[c].max() + max_extension)
for c in alts.columns
if all(alts[c].astype(str).str.isnumeric())
if all(alts[c].astype(str).str.isnumeric()) and (c != "tot_tours")
}
valid_flavors = all(
[(isinstance(flavor, str) & (num >= 0)) for flavor, num in flavors.items()]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
escort,shopping,othmaint,othdiscr,eatout,social
0,0,0,0,0,0
0,0,0,1,0,0
0,0,0,0,0,1
0,0,0,1,0,1
0,0,0,0,1,0
0,0,0,1,1,0
0,0,0,0,1,1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