Skip to content

Commit 2dda67e

Browse files
authored
Fix black formatting in trip_scheduling_choice files
1 parent 38c71bf commit 2dda67e

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

activitysim/abm/models/trip_scheduling_choice.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ def run_trip_scheduling_choice(
276276
choosers,
277277
chunk_trace_label,
278278
chunk_sizer,
279-
) in chunk.adaptive_chunked_choosers(state, indirect_tours, trace_label):
279+
) in chunk.adaptive_chunked_choosers(
280+
state,
281+
indirect_tours,
282+
trace_label,
283+
explicit_chunk_size=model_settings.explicit_chunk,
284+
):
280285
# Sort the choosers and get the schedule alternatives
281286
choosers = choosers.sort_index()
282287
schedules = generate_schedule_alternatives(choosers).sort_index()
@@ -350,7 +355,11 @@ class TripSchedulingChoiceSettings(LogitComponentSettings, extra="forbid"):
350355
Settings for the `trip_scheduling_choice` component.
351356
"""
352357

353-
pass
358+
explicit_chunk: float = 0
359+
"""
360+
If > 0, use this chunk size instead of adaptive chunking.
361+
If less than 1, use this fraction of the total number of rows.
362+
"""
354363

355364

356365
@workflow.step

activitysim/abm/test/test_misc/test_trip_scheduling_choice.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
from pathlib import Path
66

7+
from pandas.testing import assert_frame_equal
78

89
from activitysim.abm.models import trip_scheduling_choice as tsc
910
from activitysim.abm.tables.skims import skim_dict
@@ -285,3 +286,26 @@ def test_run_trip_scheduling_choice(model_spec, tours, skims, locals_dict):
285286

286287
# check that tours with no inbound stops have zero inbound duration
287288
assert out_tours[tsc.IB_DURATION].mask(in_tours[tsc.HAS_IB_STOPS], 0).sum() == 0
289+
290+
# confirm explicit chunking is supported and doesn't affect results
291+
state.settings.chunk_training_mode = "explicit"
292+
293+
model_settings_explicit_chunk = tsc.TripSchedulingChoiceSettings(
294+
**{
295+
"SPEC": "placeholder.csv",
296+
"explicit_chunk": 2,
297+
"compute_settings": {
298+
"protect_columns": ["origin", "destination", "schedule_id"]
299+
},
300+
}
301+
)
302+
out_tours_chunked = tsc.run_trip_scheduling_choice(
303+
state,
304+
model_spec,
305+
in_tours.copy(deep=True),
306+
skims,
307+
locals_dict,
308+
trace_label="PyTest Trip Scheduling",
309+
model_settings=model_settings_explicit_chunk,
310+
)
311+
assert_frame_equal(out_tours, out_tours_chunked)

0 commit comments

Comments
 (0)