Skip to content

Commit f7ad09b

Browse files
committed
Merge commit 'c34e0cf396e3acd1af27422ebd859c4e4a5bc308' into extended
2 parents dc26d7e + c34e0cf commit f7ad09b

File tree

11 files changed

+205
-28
lines changed

11 files changed

+205
-28
lines changed

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Implementation Testing
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
env:
12+
CACHE_NUMBER: 0 # increase to reset cache manually
13+
14+
jobs:
15+
foundation:
16+
17+
strategy:
18+
matrix:
19+
python-version: ["3.10"]
20+
defaults:
21+
run:
22+
shell: bash -l {0}
23+
name: linux-64-py${{ matrix.python-version }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
# checkout the code in this repository
27+
- uses: actions/checkout@v4
28+
with:
29+
path: 'activitysim-prototype-mtc'
30+
31+
# checkout the main branch of ActivitySim itself
32+
- uses: actions/checkout@v4
33+
with:
34+
repository: 'ActivitySim/activitysim'
35+
ref: main
36+
path: 'activitysim'
37+
fetch-depth: 0 # get all tags, lets setuptools_scm do its thing
38+
39+
- name: Setup Mambaforge
40+
uses: conda-incubator/setup-miniconda@v3
41+
with:
42+
miniforge-variant: Mambaforge
43+
miniforge-version: latest
44+
activate-environment: asim-test
45+
use-mamba: true
46+
python-version: ${{ matrix.python-version }}
47+
48+
- name: Set cache date for year and month
49+
run: echo "DATE=$(date +'%Y%m')" >> $GITHUB_ENV
50+
51+
- uses: actions/cache@v4
52+
with:
53+
path: /usr/share/miniconda3/envs/asim-test
54+
key: linux-64-conda-${{ hashFiles('activitysim/conda-environments/github-actions-tests.yml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
55+
id: cache
56+
57+
- name: Update environment
58+
run: |
59+
mamba env update -n asim-test -f activitysim/conda-environments/github-actions-tests.yml
60+
mamba install --yes \
61+
"psutil=5.9.5" \
62+
"pydantic=2.6.1" \
63+
"pypyr=5.8.0" \
64+
"pytables=3.6.1" \
65+
"pytest-cov" \
66+
"pytest-regressions=2.5.0" \
67+
"scikit-learn=1.2.2" \
68+
"sharrow>=2.6.0" \
69+
"simwrapper=1.8.5" \
70+
"xarray=2023.2.0" \
71+
"zarr=2.14.2" \
72+
"zstandard=0.21.0"
73+
if: steps.cache.outputs.cache-hit != 'true'
74+
75+
- name: Install activitysim
76+
# installing without dependencies is faster, we trust that all needed dependencies
77+
# are in the conda environment defined above. Also, this avoids pip getting
78+
# confused and reinstalling tables (pytables).
79+
run: |
80+
python -m pip install -e ./activitysim --no-deps
81+
82+
- name: Conda checkup
83+
run: |
84+
mamba info -a
85+
mamba list
86+
87+
- name: Test this implementation
88+
run: |
89+
python -m pytest activitysim-prototype-mtc/test
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Description,Target,Expression
22
non-motorized and walk tran and tnc set to null,selected_vehicle,np.nan
3-
tours using sov option,selected_vehicle,"np.where(df.tour_mode.isin(['DRIVEALONEFREE','DRIVEALONEPAY','DRIVE_LOC','DRIVE_LRF','DRIVE_EXP','DRIVE_HVY','DRIVE_COM']), df.vehicle_occup_1, selected_vehicle)"
4-
tours using sr2 option,selected_vehicle,"np.where(df.tour_mode.isin(['SHARED2FREE','SHARED2PAY']), df.vehicle_occup_2, selected_vehicle)"
5-
tours using sr3 option,selected_vehicle,"np.where(df.tour_mode.isin(['SHARED3FREE','SHARED3PAY']), df['vehicle_occup_3.5'], selected_vehicle)"
3+
tours using sov option,selected_vehicle,"pd.Series(np.where(df.tour_mode.isin(['DRIVEALONEFREE','DRIVEALONEPAY','DRIVE_LOC','DRIVE_LRF','DRIVE_EXP','DRIVE_HVY','DRIVE_COM']), df.vehicle_occup_1, selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
4+
tours using sr2 option,selected_vehicle,"pd.Series(np.where(df.tour_mode.isin(['SHARED2FREE','SHARED2PAY']), df.vehicle_occup_2, selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
5+
tours using sr3 option,selected_vehicle,"pd.Series(np.where(df.tour_mode.isin(['SHARED3FREE','SHARED3PAY']), df['vehicle_occup_3.5'], selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
66
parent tour vehicle,_parent_selected_vehicle,"reindex(df.selected_vehicle, df.parent_tour_id) if 'selected_vehicle' in df.columns else np.nan"
7-
assign parent tour vehicle to atwork subtours,selected_vehicle,"np.where(df.tour_category == 'atwork', _parent_selected_vehicle, selected_vehicle)"
7+
assign parent tour vehicle to atwork subtours,selected_vehicle,"pd.Series(np.where(df.tour_category == 'atwork', _parent_selected_vehicle, selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"
88
is non-driving tour,_is_non_driving_tour,"df.tour_mode.isin(['WALK','BIKE','WALK_LOC','WALK_LRF','WALK_EXP','WALK_HVY','WALK_COM','TAXI','TNC_SINGLE','TNC_SHARED'])"
9-
atwork subtours whose parent tour did not use a vehicle use non_hh_veh,selected_vehicle,"np.where(~_is_non_driving_tour & (df.tour_category == 'atwork') & pd.isna(selected_vehicle),'non_hh_veh', selected_vehicle)"
9+
atwork subtours whose parent tour did not use a vehicle use non_hh_veh,selected_vehicle,"pd.Series(np.where(~_is_non_driving_tour & (df.tour_category == 'atwork') & pd.isna(selected_vehicle),'non_hh_veh', selected_vehicle), index=df.index, dtype=df.vehicle_occup_1.dtype)"

ext-configs/tour_mode_choice_annotate_choosers_preprocessor.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ local,_DF_IS_TOUR,'tour_type' in df.columns
1717
,is_escort,(df.tour_type == 'escort') if _DF_IS_TOUR else False
1818
#Auto operating costs,,
1919
,parent_tour_veh,"reindex(tours['selected_vehicle'], df['parent_tour_id']) if 'selected_vehicle' in df.columns else np.nan"
20-
,sov_veh_option,"np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_1', np.nan))"
21-
,sr2_veh_option,"np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_2', np.nan))"
22-
,sr3p_veh_option,"np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_3.5', np.nan))"
20+
,sov_veh_option,"pd.Series(np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_1', np.nan)), index=df.index, dtype=df.vehicle_occup_1.dtype if 'vehicle_occup_1' in df.columns else np.float64)"
21+
,sr2_veh_option,"pd.Series(np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_2', np.nan)), index=df.index, dtype=df.vehicle_occup_2.dtype if 'vehicle_occup_2' in df.columns else np.float64)"
22+
,sr3p_veh_option,"pd.Series(np.where(is_atwork_subtour, parent_tour_veh, df.get('vehicle_occup_3.5', np.nan)), index=df.index, dtype=df['vehicle_occup_3.5'].dtype if 'vehicle_occup_3.5' in df.columns else np.float64)"
2323
,sov_auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(sov_veh_option, df.index)) if 'vehicle_occup_1' in df.columns else np.nan"
2424
,sov_auto_op_cost,"np.where(sov_auto_op_cost.isna() | (pd.Series(sov_veh_option, df.index) == 'non_hh_veh'), costPerMile, sov_auto_op_cost)"
2525
,sr2_auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(sr2_veh_option, df.index)) if 'vehicle_occup_2' in df.columns else np.nan"

ext-configs/trip_mode_choice_annotate_trips_preprocessor.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Description,Target,Expression
1919
,tour_mode_is_drive_transit,i_tour_mode.isin(I_DRIVE_TRANSIT_MODES)
2020
,tour_mode_is_ride_hail,i_tour_mode.isin(I_RIDE_HAIL_MODES)
2121
#,,
22-
,selected_tour_vehicle,"reindex(tours.selected_vehicle, df.tour_id)"
22+
,selected_tour_vehicle,"pd.Series(reindex(tours.selected_vehicle, df.tour_id), index=df.index, dtype=tours.selected_vehicle.dtype)"
2323
,auto_op_cost,"reindex(vehicles.groupby('vehicle_type')['auto_operating_cost'].mean(), pd.Series(selected_tour_vehicle, df.index))"
2424
,auto_op_cost,"np.where(pd.isna(auto_op_cost), costPerMile, auto_op_cost)"
2525
,inbound,~df.outbound

test/configs/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use_shadow_pricing: False
1414
# (if True, tables will be written if DEST_CHOICE_SAMPLE_TABLE_NAME is specified in individual model settings)
1515
want_dest_choice_sample_tables: False
1616

17-
cleanup_pipeline_after_run: True
17+
cleanup_pipeline_after_run: False
1818

1919
output_tables:
2020
h5_store: False

test/configs_mp/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ households_sample_size: 10
2020
# (if True, tables will be written if DEST_CHOICE_SAMPLE_TABLE_NAME is specified in individual model settings)
2121
want_dest_choice_sample_tables: False
2222

23-
cleanup_pipeline_after_run: True
23+
cleanup_pipeline_after_run: False
2424

2525
output_tables:
2626
h5_store: False

test/ext-configs/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ output_tables:
4242
- vehicles
4343
- proto_disaggregate_accessibility
4444

45-
recode_pipeline_columns: False
45+
recode_pipeline_columns: True
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
inherit_settings: True
2+
3+
# read cached skims (using numpy memmap) from output directory (memmap is faster than omx )
4+
read_skim_cache: False
5+
# write memmapped cached skims to output directory after reading from omx, for use in subsequent runs
6+
write_skim_cache: False
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
inherit_settings: True
2+
3+
# treat warnings as errors
4+
strict: True
5+
6+
# number of households to simulate
7+
households_sample_size: 10
8+
chunk_size: 0
9+
chunk_training_mode: disabled
10+
11+
# - shadow pricing global switches
12+
use_shadow_pricing: False
13+
14+
# turn writing of sample_tables on and off for all models
15+
# (if True, tables will be written if DEST_CHOICE_SAMPLE_TABLE_NAME is specified in individual model settings)
16+
want_dest_choice_sample_tables: False
17+
18+
cleanup_pipeline_after_run: True
19+
20+
output_tables:
21+
h5_store: False
22+
action: include
23+
prefix: final_
24+
sort: True
25+
tables:
26+
- tablename: trips
27+
decode_columns:
28+
origin: land_use.zone_id
29+
destination: land_use.zone_id
30+
31+
recode_pipeline_columns: True

test/ext-configs_mp/settings.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ households_sample_size: 10
1717
# - shadow pricing global switches
1818
# turn shadow_pricing on and off for all models (e.g. school and work)
1919
# see shadow_pricing.yaml for additional settings
20-
use_shadow_pricing: True
20+
use_shadow_pricing: False
2121

2222
# turn writing of sample_tables on and off for all models
2323
# (if True, tables will be written if DEST_CHOICE_SAMPLE_TABLE_NAME is specified in individual model settings)
2424
want_dest_choice_sample_tables: False
2525

26-
cleanup_pipeline_after_run: True
26+
cleanup_pipeline_after_run: False
2727

2828
trace_hh_id:
2929
# global switch to turn on or off presampling of destination alternatives at TAZ level (multizone models only)
3030
want_dest_choice_presampling: True
3131

32-
recode_pipeline_columns: False
32+
recode_pipeline_columns: True
3333

3434
output_tables:
3535
h5_store: False

0 commit comments

Comments
 (0)