Skip to content

Commit 1af9c34

Browse files
committed
make coding for chunking for generic for other location models
- person_id is not compatible for tour and trip destination models, should use tour_id or trip_id instead - to make this variable for generic, the code will now use the first column in the alternative data file
1 parent 425467e commit 1af9c34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

activitysim/estimation/larch/location_choice.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,13 @@ def split(a, n):
204204
time_start = datetime.now()
205205
# calculate num_chunks based on chunking_size (or max number of rows per chunk)
206206
num_chunks = int(len(alt_values) / chunking_size)
207-
all_person_ids = list(alt_values["person_id"].unique())
208-
split_ids = list(split(all_person_ids, num_chunks))
207+
id_col_name = alt_values.columns[0]
208+
all_ids = list(alt_values[id_col_name].unique())
209+
split_ids = list(split(all_ids, num_chunks))
209210
x_ca_list = []
210211
i = 0
211212
for chunk_ids in split_ids:
212-
alt_values_i = alt_values[alt_values["person_id"].isin(chunk_ids)]
213+
alt_values_i = alt_values[alt_values[id_col_name].isin(chunk_ids)]
213214
x_ca_i = cv_to_ca(
214215
alt_values_i.set_index([chooser_index_name, alt_values_i.columns[1]])
215216
)

0 commit comments

Comments
 (0)