Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 1 addition & 3 deletions activitysim/abm/models/joint_tour_frequency_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ def joint_tour_frequency_composition(
model_settings_file_name,
)

# FIXME setting index as "alt" causes crash in estimation mode...
alts = simulate.read_model_alts(
state, "joint_tour_frequency_composition_alternatives.csv", set_index=None
state, "joint_tour_frequency_composition_alternatives.csv", set_index="alt"
)
alts.index = alts["alt"].values

# - only interested in households with more than one cdap travel_active person and
# - at least one non-preschooler
Expand Down
14 changes: 5 additions & 9 deletions activitysim/abm/models/school_escorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def create_school_escorting_bundles_table(choosers, tours, stage):
bundles["chauf_id"],
)

bundles["Alt"] = choosers["Alt"]
bundles["alt"] = choosers["alt"]
bundles["Description"] = choosers["Description"]

return bundles
Expand Down Expand Up @@ -412,11 +412,7 @@ def school_escorting(

trace_hh_id = state.settings.trace_hh_id

# FIXME setting index as "Alt" causes crash in estimation mode...
# happens in joint_tour_frequency_composition too!
# alts = simulate.read_model_alts(state, model_settings.ALTS, set_index="Alt")
alts = simulate.read_model_alts(state, model_settings.ALTS, set_index=None)
alts.index = alts["Alt"].values
alts = simulate.read_model_alts(state, model_settings.ALTS, set_index="alt")

choosers, participant_columns = determine_escorting_participants(
households_merged, persons, model_settings
Expand Down Expand Up @@ -565,10 +561,10 @@ def school_escorting(
)

if stage_num >= 1:
choosers["Alt"] = choices
choosers = choosers.join(alts.set_index("Alt"), how="left", on="Alt")
choosers["alt"] = choices
choosers = choosers.join(alts, how="left", on="alt")
bundles = create_school_escorting_bundles_table(
choosers[choosers["Alt"] > 1], tours, stage
choosers[choosers["alt"] > 1], tours, stage
)
escort_bundles.append(bundles)

Expand Down
15 changes: 15 additions & 0 deletions activitysim/core/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,22 @@ def read_model_alts(state: workflow.State, file_name, set_index=None):
file_path = state.filesystem.get_config_file_path(file_name)
df = pd.read_csv(file_path, comment="#")
if set_index:
if "Alt" in df.columns:
# Handle deprecated ALTS index
warnings.warn(
"Support for 'Alt' column name in alternatives files will be removed."
" Use 'alt' (lowercase) instead.",
DeprecationWarning,
)
# warning above does not actually output to logger, so also log it
logger.warning(
"Support for 'Alt' column name in alternatives files will be removed."
" Use 'alt' (lowercase) instead."
)
df.rename(columns={"Alt": "alt"}, inplace=True)

df.set_index(set_index, inplace=True)

return df


Expand Down
2 changes: 1 addition & 1 deletion activitysim/core/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_df_from_dict():
df = pd.DataFrame({"attrib": [1, 2, 2, 3, 1]}, index=index)

# scramble index order for one expression and not the other
sorted = df.eval("attrib.sort_values()")
sorted = df.eval("attrib.sort_values(kind='mergesort')")
not_sorted = df.eval("attrib * 1")

# check above expressions
Expand Down
Loading