Skip to content

Commit

Permalink
correct veh type alts indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensle committed Feb 6, 2024
1 parent dde3d8b commit 3f9b809
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions activitysim/abm/models/vehicle_type_choice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3f9b809

Please sign in to comment.