From 3f9b809a3125d8afe033c0c5021c2240a84a2de9 Mon Sep 17 00:00:00 2001 From: David Hensle Date: Mon, 5 Feb 2024 17:18:49 -0800 Subject: [PATCH] correct veh type alts indexing --- activitysim/abm/models/vehicle_type_choice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/activitysim/abm/models/vehicle_type_choice.py b/activitysim/abm/models/vehicle_type_choice.py index a93399205d..071061cb89 100644 --- a/activitysim/abm/models/vehicle_type_choice.py +++ b/activitysim/abm/models/vehicle_type_choice.py @@ -256,6 +256,7 @@ def construct_model_alternatives( alts_wide.set_index(["body_type", "age", "fuel_type"]).index ) ].reset_index() + alts_long.index = alts_wide.index alts_wide.drop(columns="_merge", inplace=True) # converting age to integer to allow interactions in utilities @@ -466,11 +467,11 @@ def iterate_vehicle_type_choice( alts = ( alts_long[alts_long.columns] .apply(lambda row: "_".join(row.values.astype(str)), axis=1) - .values + .to_dict() ) else: - alts = model_spec.columns - choices["vehicle_type"] = choices["vehicle_type"].map(dict(enumerate(alts))) + alts = enumerate(dict(model_spec.columns)) + choices["vehicle_type"] = choices["vehicle_type"].map(alts) # STEP II: append probabilistic vehicle type attributes if probs_spec_file is not None: