Skip to content

Commit

Permalink
revert drop inplace
Browse files Browse the repository at this point in the history
  • Loading branch information
i-am-sijia committed Mar 26, 2024
1 parent 279987b commit b6fd307
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
6 changes: 3 additions & 3 deletions activitysim/abm/models/trip_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ def choose_trip_destination(
destination_sample = trip_destination_sample(
state,
primary_purpose=primary_purpose,
trips=trips.copy(),
trips=trips,
alternatives=alternatives,
model_settings=model_settings,
size_term_matrix=size_term_matrix,
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def choose_trip_destination(
destination_sample = compute_logsums(
state,
primary_purpose=primary_purpose,
trips=trips.copy(),
trips=trips,
destination_sample=destination_sample,
tours_merged=tours_merged,
model_settings=model_settings,
Expand All @@ -1036,7 +1036,7 @@ def choose_trip_destination(
destinations = trip_destination_simulate(
state,
primary_purpose=primary_purpose,
trips=trips.copy(),
trips=trips,
destination_sample=destination_sample,
model_settings=model_settings,
want_logsums=want_logsums,
Expand Down
23 changes: 11 additions & 12 deletions activitysim/core/interaction_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,19 @@ def _interaction_sample(
unique_variables_in_spec.add("tour_mode")
logger.info("Dropping unused variables in chooser table")

if "school_escorting" not in trace_label:
logger.info(
"before dropping, the choosers table has {} columns: {}".format(
len(choosers.columns), choosers.columns
)
logger.info(
"before dropping, the choosers table has {} columns: {}".format(
len(choosers.columns), choosers.columns
)
for c in choosers.columns:
if c not in unique_variables_in_spec:
choosers.drop(c, axis=1, inplace=True)
logger.info(
"after dropping, the choosers table has {} columns: {}".format(
len(choosers.columns), choosers.columns
)
)
for c in choosers.columns:
if c not in unique_variables_in_spec:
choosers = choosers.drop(c, axis=1)
logger.info(
"after dropping, the choosers table has {} columns: {}".format(
len(choosers.columns), choosers.columns
)
)

if sharrow_enabled:
(
Expand Down
7 changes: 3 additions & 4 deletions activitysim/core/interaction_sample_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@ def _interaction_sample_simulate(
unique_variables_in_spec.add("parent_tour_id")
logger.info("Dropping unused variables in chooser table")

if "school_escorting" not in trace_label:
for c in choosers.columns:
if c not in unique_variables_in_spec:
choosers.drop(c, axis=1, inplace=True)
for c in choosers.columns:
if c not in unique_variables_in_spec:
choosers = choosers.drop(c, axis=1)

interaction_df = alternatives.join(choosers, how="left", rsuffix="_chooser")
logger.info(
Expand Down
7 changes: 3 additions & 4 deletions activitysim/core/interaction_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,9 @@ def _interaction_simulate(

logger.info("Dropping unused variables in chooser table")

if "school_escorting" not in trace_label:
for c in choosers.columns:
if c not in unique_variables_in_spec:
choosers.drop(c, axis=1, inplace=True)
for c in choosers.columns:
if c not in unique_variables_in_spec:
choosers = choosers.drop(c, axis=1)

if locals_d is not None and locals_d.get("_sharrow_skip", False):
sharrow_enabled = False
Expand Down

0 comments on commit b6fd307

Please sign in to comment.