@@ -242,14 +242,10 @@ def location_sample(
242242 chunk_tag ,
243243 trace_label ,
244244):
245- # FIXME - MEMORY HACK - only include columns actually used in spec
246- chooser_columns = model_settings .SIMULATE_CHOOSER_COLUMNS
247- # Drop this when PR #1017 is merged
248- if ("household_id" not in chooser_columns ) and (
249- "household_id" in persons_merged .columns
250- ):
251- chooser_columns = chooser_columns + ["household_id" ]
252- choosers = persons_merged [chooser_columns ]
245+ # The former column selection returned an independent frame. Preserve that
246+ # isolation so component preprocessors cannot leak annotations into the
247+ # shared persons table or into later location-choice segments.
248+ choosers = persons_merged .copy ()
253249
254250 # create wrapper with keys for this lookup - in this case there is a home_zone_id in the choosers
255251 # and a zone_id in the alternatives which get merged during interaction
@@ -441,17 +437,8 @@ def location_presample(
441437 HOME_TAZ in persons_merged
442438 ) # 'TAZ' should already be in persons_merged from land_use
443439
444- # FIXME - MEMORY HACK - only include columns actually used in spec
445- # FIXME we don't actually require that land_use provide a TAZ crosswalk
446- # FIXME maybe we should add it for multi-zone (from maz_taz) if missing?
447- chooser_columns = model_settings .SIMULATE_CHOOSER_COLUMNS
448- chooser_columns = [HOME_TAZ if c == HOME_MAZ else c for c in chooser_columns ]
449- # Drop this when PR #1017 is merged
450- if ("household_id" not in chooser_columns ) and (
451- "household_id" in persons_merged .columns
452- ):
453- chooser_columns = chooser_columns + ["household_id" ]
454- choosers = persons_merged [chooser_columns ]
440+ # Keep chooser annotations local to this model segment.
441+ choosers = persons_merged .copy ()
455442
456443 # create wrapper with keys for this lookup - in this case there is a HOME_TAZ in the choosers
457444 # and a DEST_TAZ in the alternatives which get merged during interaction
@@ -627,11 +614,6 @@ def run_location_logsums(
627614 mandatory = False ,
628615 )
629616
630- # FIXME - MEMORY HACK - only include columns actually used in spec
631- persons_merged_df = logsum .filter_chooser_columns (
632- persons_merged_df , logsum_settings , model_settings
633- )
634-
635617 logger .info (f"Running { trace_label } with { len (location_sample_df .index )} rows" )
636618
637619 choosers = location_sample_df .join (persons_merged_df , how = "left" )
@@ -691,14 +673,9 @@ def run_location_simulate(
691673 """
692674 assert not persons_merged .empty
693675
694- # FIXME - MEMORY HACK - only include columns actually used in spec
695- chooser_columns = model_settings .SIMULATE_CHOOSER_COLUMNS
696- # Drop this when PR #1017 is merged
697- if ("household_id" not in chooser_columns ) and (
698- "household_id" in persons_merged .columns
699- ):
700- chooser_columns = chooser_columns + ["household_id" ]
701- choosers = persons_merged [chooser_columns ]
676+ # Preprocessors annotate choosers in place. Use a copy so those temporary
677+ # columns do not affect subsequent segments that share persons_merged.
678+ choosers = persons_merged .copy ()
702679
703680 alt_dest_col_name = model_settings .ALT_DEST_COL_NAME
704681
0 commit comments