Skip to content

Commit 8e17c61

Browse files
dhenslejpn--
andauthored
trace proto tables if available, otherwise synthetic population (#901)
Co-authored-by: Jeffrey Newman <[email protected]>
1 parent 39c5e12 commit 8e17c61

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

activitysim/abm/models/disaggregate_accessibility.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,10 +922,6 @@ def compute_disaggregate_accessibility(
922922
for ch in list(state.get_rn_generator().channels.keys()):
923923
state.get_rn_generator().drop_channel(ch)
924924

925-
# Drop any prematurely added traceables
926-
for trace in [x for x in state.tracing.traceable_tables if "proto_" not in x]:
927-
state.tracing.deregister_traceable_table(trace)
928-
929925
# # need to clear any premature tables that were added during the previous run
930926
for name in list(state.existing_table_status):
931927
if name not in tables_prior:
@@ -954,4 +950,8 @@ def compute_disaggregate_accessibility(
954950
)
955951
state.add_table(tablename, df)
956952

953+
# drop all proto-related tables and make way for synthetic population
954+
for trace in state.tracing.traceable_tables:
955+
state.tracing.deregister_traceable_table(trace)
956+
957957
return

activitysim/core/workflow/tracing.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,18 +506,19 @@ def interaction_trace_rows(self, interaction_df, choosers, sample_size=None):
506506

507507
traceable_table_ids = self.traceable_table_ids
508508

509-
# Determine whether actual tables or proto_ tables for disaggregate accessibilities
510-
persons_table_name = set(traceable_table_ids).intersection(
511-
["persons", "proto_persons"]
512-
)
513-
households_table_name = set(traceable_table_ids).intersection(
514-
["households", "proto_households"]
509+
# trace proto tables if they exist, otherwise trace actual tables
510+
# proto tables are used for disaggregate accessibilities and
511+
# are removed from the traceable_table_ids after the accessibilities are created
512+
households_table_name = (
513+
"proto_households"
514+
if "proto_households" in traceable_table_ids.keys()
515+
else "households"
515516
)
516517

517-
assert len(persons_table_name) == 1 and len(persons_table_name) == 1
518-
persons_table_name, households_table_name = (
519-
persons_table_name.pop(),
520-
households_table_name.pop(),
518+
persons_table_name = (
519+
"proto_persons"
520+
if "proto_persons" in traceable_table_ids.keys()
521+
else "persons"
521522
)
522523

523524
if (

0 commit comments

Comments
 (0)