diff --git a/activitysim/abm/models/joint_tour_frequency_composition.py b/activitysim/abm/models/joint_tour_frequency_composition.py index 1fffd892a..cc7f82c0d 100644 --- a/activitysim/abm/models/joint_tour_frequency_composition.py +++ b/activitysim/abm/models/joint_tour_frequency_composition.py @@ -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 diff --git a/activitysim/abm/models/school_escorting.py b/activitysim/abm/models/school_escorting.py index 32e5058e7..491d0ac0c 100644 --- a/activitysim/abm/models/school_escorting.py +++ b/activitysim/abm/models/school_escorting.py @@ -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 @@ -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 @@ -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) diff --git a/activitysim/core/simulate.py b/activitysim/core/simulate.py index 55caf050a..7ced099d9 100644 --- a/activitysim/core/simulate.py +++ b/activitysim/core/simulate.py @@ -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 diff --git a/activitysim/examples/prototype_mtc_extended/test/prototype_mtc_extended_reference_pipeline.zip b/activitysim/examples/prototype_mtc_extended/test/prototype_mtc_extended_reference_pipeline.zip index 41ed28ba2..9654facfb 100644 Binary files a/activitysim/examples/prototype_mtc_extended/test/prototype_mtc_extended_reference_pipeline.zip and b/activitysim/examples/prototype_mtc_extended/test/prototype_mtc_extended_reference_pipeline.zip differ diff --git a/docs/dev-guide/changes.md b/docs/dev-guide/changes.md index 2cd584b3c..b86a9d84c 100644 --- a/docs/dev-guide/changes.md +++ b/docs/dev-guide/changes.md @@ -13,6 +13,15 @@ branch (i.e., the main branch on GitHub), but not yet released in a stable versi of ActivitySim. See below under the various version headings for changes in released versions. +## v1.5.2 + +### Alternative file naming consistency + +We have enforced a naming scheme for alternative config files to have the index name +be 'alt' instead of 'Alt'. This is to maintain consistency across all config files. +The code will handle this for you, but you will get a deprecation warning if you +are using 'Alt' in your config files. Please update your config files to use 'alt'. +See ActivitySim issue [#846](https://github.com/ActivitySim/activitysim/issues/846) ## v1.5.1