Skip to content

Commit

Permalink
Makes tests faster by limiting demand.
Browse files Browse the repository at this point in the history
Fixes issues with PAT PDT parameters.
  • Loading branch information
e-lo committed Jun 23, 2018
1 parent 37a10a0 commit b4a2cfc
Show file tree
Hide file tree
Showing 19 changed files with 385 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ install:
- pip install -r requirements.txt
- pip install .
script:
- if [ "$TRAVIS_BRANCH" == "master" ] | [ "$TRAVIS_BRANCH" == "develop" ]; then travis_wait 70 py.test;
- if [ "$TRAVIS_BRANCH" == "master" ] | [ "$TRAVIS_BRANCH" == "develop" ]; then travis_wait 70 py.test -v -m travis;
else travis_wait 30 py.test -v -m basic;
fi
285 changes: 276 additions & 9 deletions Notebooks/Test Networks.ipynb

Large diffs are not rendered by default.

123 changes: 61 additions & 62 deletions fasttrips/Examples/demand/psrc_1_1/pathweight_ft.txt
Original file line number Diff line number Diff line change
@@ -1,62 +1,61 @@
purpose user_class demand_mode_type demand_mode supply_mode weight_name weight_value
work lowinc transfer transfer transfer walk_time_min 0.04
work lowinc transfer transfer transfer transfer_penalty 0.24
work lowinc access walk walk_access arrive_early_min 1.2
work lowinc access walk walk_access depart_late_min 1.2
work lowinc access PNR PNR_access walk_time_min 0.04
work lowinc access PNR PNR_access drive_travel_time_min 0.03
work lowinc egress walk walk_egress time_min 0.04
work lowinc egress walk walk_egress preferred_delay_min 0.024
work lowinc egress walk walk_egress arrive_early_min 1.2
work lowinc egress walk walk_egress depart_late_min 1.2
work lowinc transit transit local_bus wait_time_min 0.05
work lowinc transit transit premium_bus in_vehicle_time_min 0.02
work lowinc transit transit premium_bus wait_time_min 0.04
work lowinc transit transit commuter_rail in_vehicle_time_min 0.02
work lowinc transit transit commuter_rail wait_time_min 0.04
work medhighinc transfer transfer transfer walk_time_min 0.058
work medhighinc transfer transfer transfer transfer_penalty 0.24
work medhighinc access walk walk_access preferred_delay_min 0.038
work medhighinc access walk walk_access time_min 0.042
work medhighinc access walk walk_access arrive_early_min 1.9
work medhighinc access walk walk_access depart_late_min 1.9
work medhighinc egress walk walk_egress time_min 0.042
work medhighinc egress walk walk_egress preferred_delay_min 0.026
work medhighinc egress PNR PNR_egress drive_travel_time_min 0.032
work medhighinc transit transit local_bus in_vehicle_time_min 0.042
work medhighinc egress walk walk_egress arrive_early_min 1.3
work medhighinc egress walk walk_egress depart_late_min 1.3
work medhighinc transit transit premium_bus wait_time_min 0.042
work medhighinc transit transit commuter_rail in_vehicle_time_min 0.022
work medhighinc transit transit commuter_rail wait_time_min 0.042
social lowinc transfer transfer transfer walk_time_min 0.04
social lowinc transfer transfer transfer transfer_penalty 0.24
social lowinc access walk walk_access preferred_delay_min 0.024
social lowinc access walk walk_access time_min 0.04
social lowinc access PNR PNR_access walk_time_min 0.04
social lowinc access PNR PNR_access drive_travel_time_min 0.03
social lowinc access walk walk_access arrive_early_min 1.2
social lowinc access walk walk_access depart_late_min 1.2
social lowinc egress PNR PNR_egress drive_travel_time_min 0.03
social lowinc transit transit local_bus in_vehicle_time_min 0.02
social lowinc transit transit local_bus wait_time_min 0.05
social lowinc transit transit premium_bus in_vehicle_time_min 0.02
social lowinc egress walk walk_egress arrive_early_min 1.2
social lowinc egress walk walk_egress depart_late_min 1.2
social lowinc transit transit commuter_rail wait_time_min 0.04
social medhighinc transfer transfer transfer walk_time_min 0.062
social medhighinc transfer transfer transfer transfer_penalty 0.24
social medhighinc access walk walk_access preferred_delay_min 0.026
social medhighinc access walk walk_access time_min 0.042
social medhighinc access PNR PNR_access walk_time_min 0.042
social medhighinc access PNR PNR_access drive_travel_time_min 0.032
social medhighinc egress walk walk_egress time_min 0.042
social medhighinc egress walk walk_egress preferred_delay_min 0.026
social medhighinc access walk walk_access arrive_early_min 1.3
social medhighinc access walk walk_access depart_late_min 1.3
social medhighinc transit transit local_bus wait_time_min 0.052
social medhighinc transit transit premium_bus in_vehicle_time_min 0.022
social medhighinc transit transit premium_bus wait_time_min 0.042
social medhighinc transit transit commuter_rail in_vehicle_time_min 0.022
social medhighinc egress walk walk_egress arrive_early_min 1.3
social medhighinc egress walk walk_egress depart_late_min 1.3
purpose user_class demand_mode_type demand_mode supply_mode weight_name weight_value
work lowinc transfer transfer transfer walk_time_min 0.04
work lowinc transfer transfer transfer transfer_penalty 0.24
work lowinc access walk walk_access time_min 0.04
work lowinc access walk walk_access arrive_early_min 1.2
work lowinc access walk walk_access depart_late_min 1.2
work lowinc access PNR PNR_access walk_time_min 0.04
work lowinc access PNR PNR_access drive_travel_time_min 0.03
work lowinc egress walk walk_egress time_min 0.04
work lowinc egress walk walk_egress arrive_early_min 1.2
work lowinc egress PNR PNR_egress walk_time_min 0.04
work lowinc egress PNR PNR_egress drive_travel_time_min 0.03
work lowinc transit transit local_bus wait_time_min 0.05
work lowinc transit transit premium_bus in_vehicle_time_min 0.02
work lowinc transit transit premium_bus wait_time_min 0.04
work lowinc transit transit commuter_rail in_vehicle_time_min 0.02
work lowinc transit transit commuter_rail wait_time_min 0.04
work medhighinc transfer transfer transfer walk_time_min 0.058
work medhighinc transfer transfer transfer transfer_penalty 0.24
work medhighinc access walk walk_access time_min 0.042
work medhighinc access walk walk_access arrive_early_min 1.9
work medhighinc access walk walk_access depart_late_min 1.9
work medhighinc access PNR PNR_access walk_time_min 0.04
work medhighinc access PNR PNR_access drive_travel_time_min 0.032
work medhighinc egress walk walk_egress time_min 0.042
work medhighinc egress walk walk_egress arrive_early_min 1.3
work medhighinc egress PNR PNR_egress walk_time_min 0.04
work medhighinc egress PNR PNR_egress drive_travel_time_min 0.032
work medhighinc transit transit local_bus in_vehicle_time_min 0.042
work medhighinc transit transit commuter_rail in_vehicle_time_min 0.022
work medhighinc transit transit commuter_rail wait_time_min 0.042
social lowinc transfer transfer transfer walk_time_min 0.04
social lowinc transfer transfer transfer transfer_penalty 0.24
social lowinc access walk walk_access time_min 0.04
social lowinc access walk walk_access arrive_early_min 1.2
social lowinc access walk walk_access depart_late_min 1.2
social lowinc access PNR PNR_access walk_time_min 0.04
social lowinc access PNR PNR_access drive_travel_time_min 0.03
social lowinc egress walk walk_access time_min 0.04
social lowinc egress walk walk_egress arrive_early_min 1.2
social lowinc egress PNR PNR_egress walk_time_min 0.04
social lowinc egress PNR PNR_egress drive_travel_time_min 0.03
social lowinc transit transit local_bus in_vehicle_time_min 0.02
social lowinc transit transit local_bus wait_time_min 0.05
social lowinc transit transit premium_bus in_vehicle_time_min 0.02
social lowinc transit transit commuter_rail wait_time_min 0.04
social medhighinc transfer transfer transfer walk_time_min 0.062
social medhighinc transfer transfer transfer transfer_penalty 0.24
social medhighinc access walk walk_access time_min 0.042
social medhighinc access walk walk_access arrive_early_min 1.3
social medhighinc access walk walk_access depart_late_min 1.3
social medhighinc access PNR PNR_access walk_time_min 0.042
social medhighinc access PNR PNR_access drive_travel_time_min 0.032
social medhighinc egress walk walk_egress time_min 0.042
social medhighinc egress walk walk_egress arrive_early_min 1.3
social medhighinc egress PNR PNR_egress walk_time_min 0.042
social medhighinc egress PNR PNR_egress drive_travel_time_min 0.032
social medhighinc transit transit local_bus wait_time_min 0.052
social medhighinc transit transit premium_bus in_vehicle_time_min 0.022
social medhighinc transit transit premium_bus wait_time_min 0.042
social medhighinc transit transit commuter_rail in_vehicle_time_min 0.022
4 changes: 3 additions & 1 deletion fasttrips/PathSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def calculate_cost(STOCH_DISPERSION, pathset_paths_df, pathset_links_df, veh_tri
PathSet.WEIGHTS_COLUMN_SUPPLY_MODE],
how ="inner")

# update the fare weight placeholder (ivt pathweight - utils per min)) based on value of time (currency per hour)
# update the fare weight placeholder (ivt pathweight - utils per min)) based on value of time (currency per hour)
# since generalized cost is in utils, (ivt utils/min)x(60 min/1 hour)x(hour/vot currency) is the weight (utils/currency)
cost_df.loc[ cost_df[PathSet.WEIGHTS_COLUMN_WEIGHT_NAME]==Assignment.SIM_COL_PAX_FARE, "weight_value" ] *= 60.0/cost_df[Passenger.TRIP_LIST_COLUMN_VOT]

Expand Down Expand Up @@ -1149,6 +1149,8 @@ def calculate_cost(STOCH_DISPERSION, pathset_paths_df, pathset_links_df, veh_tri

# abort here if we're missing anything
if len(missing_accegr_costs) + len(missing_trip_costs) + len(missing_transfer_costs) > 0:
abort_error_msg = "\nMissing %d accegr_costs\nMissing %d trip_costs\nMissing %d transfer_costs" % (len(missing_accegr_costs), len(missing_trip_costs), len(missing_transfer_costs))
FastTripsLogger.debug(abort_error_msg)
raise NotImplementedError("Missing var_values; See log")

##################### Put them back together into a single dataframe
Expand Down
2 changes: 1 addition & 1 deletion tests/test_assignment_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_assignment_type(assignment_type):
pathfinding_type = assignment_type,
iters = 1,
dispersion = 0.50,
test_size = 2)
num_trips = 5)

assert r["passengers_arrived"] > 0

Expand Down
1 change: 1 addition & 0 deletions tests/test_bunny.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


@pytest.mark.basic
@pytest.mark.travis
def test_bunny(demand, network):
"""
Test to ensure that the most simple of networks and demand is working.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_calculate_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
PATHSET_PATHS_CTL = os.path.join(DF_DIR, 'control_result_pathset_paths.csv')
PATHSET_LINKS_CTL = os.path.join(DF_DIR, 'control_result_pathset_links.csv')


@pytest.mark.travis
def test_growth_type_cost_calculation():
sample_data = {
'weight_value': [3.93, .03, .3, .56],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run_convergence():
capacity=True,
iters=4,
dispersion=0.50,
test_size= 10,
num_trips= 10,
)


Expand Down
15 changes: 6 additions & 9 deletions tests/test_dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
import pytest
from fasttrips import Run

test_thetas = [1.0, 0.5, 0.1]
test_size = 5

@pytest.fixture(scope='module', params=[1.0, 0.7, 0.5, 0.4, 0.1])
@pytest.fixture(scope='module', params=test_thetas)
def dispersion_rate(request):
return request.param

@pytest.fixture(scope='module')
def passengers_arrived(dispersion_rate):
arrived = {
1.0: 726,
0.7: 726,
0.5: 726,
0.4: 726,
0.1: 726,
}
arrived = dict(zip(test_thetas,[test_size]*len(test_thetas)))

return arrived[dispersion_rate]

@pytest.mark.travis
def test_dispersion(dispersion_rate, passengers_arrived):

EXAMPLES_DIR = os.path.join(os.getcwd(), "fasttrips", "Examples",)
Expand All @@ -44,6 +41,6 @@ def test_dispersion(dispersion_rate, passengers_arrived):
pathfinding_type = "stochastic",
iters = 1,
dispersion = dispersion_rate,
test_size = 100 )
num_trips = test_size )

assert passengers_arrived == r["passengers_arrived"]
2 changes: 1 addition & 1 deletion tests/test_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def network_results(network):
}
yield results[network]


@pytest.mark.travis
def test_calculate_distance_miles():
orig_lat, orig_lon = 32.707431, -117.157058
dest_lat, dest_lon = 32.740792, -117.211333
Expand Down
17 changes: 14 additions & 3 deletions tests/test_fares.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
import pytest
from fasttrips import Run

@pytest.mark.parametrize("ignore_PF_fares", [True])
@pytest.mark.parametrize("ignore_EN_fares", [False, True])

ignore_PF_fares_options = [True]
ignore_EN_fares_options = [False, True]

@pytest.mark.parametrize("ignore_PF_fares", ignore_PF_fares_options)
@pytest.mark.parametrize("ignore_EN_fares", ignore_EN_fares_options)

@pytest.mark.travis
def test_fares(ignore_PF_fares,ignore_EN_fares):

EXAMPLES_DIR = os.path.join(os.getcwd(), "fasttrips", "Examples")
Expand All @@ -26,8 +31,14 @@ def test_fares(ignore_PF_fares,ignore_EN_fares):
overlap_variable = "None",
iters = 1,
dispersion = 0.50,
test_size = 2,
num_trips = 5,
transfer_fare_ignore_pathfinding = ignore_PF_fares,
transfer_fare_ignore_pathenum = ignore_EN_fares)

assert r["passengers_arrived"] > 0

if __name__ == '__main__':
import itertools
for ignore_PF_fares,ignore_EN_fares in list(itertools.product(ignore_PF_fares_options, ignore_EN_fares_options)):
print("running %s %s" % (ignore_PF_fares,ignore_EN_fares))
test_fares(ignore_PF_fares,ignore_EN_fares)
2 changes: 2 additions & 0 deletions tests/test_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@pytest.mark.parametrize("feedback_iters", [3])
@pytest.mark.parametrize("capacity_const", [False, True])

@pytest.mark.travis
def test_feedback(feedback_iters,capacity_const):

EXAMPLES_DIR = os.path.join(os.getcwd(), "fasttrips", "Examples")
Expand All @@ -26,6 +27,7 @@ def test_feedback(feedback_iters,capacity_const):
pathfinding_type = "stochastic",
capacity = capacity_const,
iters = feedback_iters,
num_trips = 5,
dispersion = 0.50)

assert r["passengers_arrived"] > 0
12 changes: 5 additions & 7 deletions tests/test_maxStopProcessCount.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
import pytest
from fasttrips import Run

test_mspc = [10, 50, 100]
test_size = 5

@pytest.fixture(scope='module', params=[10, 50, 100])
@pytest.fixture(scope='module', params=test_mspc)
def stop_process_count(request):
return request.param


@pytest.fixture(scope='module')
def passengers_arrived(stop_process_count):
arrived = {
10: 726,
50: 726,
100: 726,
}
arrived = dict(zip(test_mspc,[test_size]*len(test_mspc)))

return arrived[stop_process_count]

Expand All @@ -39,7 +37,7 @@ def test_max_stop_process_count(stop_process_count, passengers_arrived):
pathfinding_type = "stochastic",
max_stop_process_count = stop_process_count,
iters = 1,
test_size = 2,
num_trips = test_size ,
dispersion = 0.50 )

assert passengers_arrived == r["passengers_arrived"]
4 changes: 2 additions & 2 deletions tests/test_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@pytest.mark.parametrize("overlap_var", OVERLAP_VARIABLES)
@pytest.mark.parametrize("split_links", [False, True])


@pytest.mark.travis
def test_overlap(overlap_var, split_links ):
EXAMPLES_DIR = os.path.join(os.getcwd(), "fasttrips", "Examples")

Expand All @@ -30,6 +30,6 @@ def test_overlap(overlap_var, split_links ):
overlap_split_transit = split_links,
iters = 1,
dispersion = 0.50,
test_size = 2)
num_trips = 5)

assert r["passengers_arrived"] > 0
2 changes: 1 addition & 1 deletion tests/test_pat_variation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from fasttrips import PathSet
from fasttrips import Run


@pytest.mark.travis
def test_pat_before_and_after():
"""
Test to ensure that some of the pathfinder trips are returned before preferred departure
Expand Down
6 changes: 3 additions & 3 deletions tests/test_penalty_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from fasttrips import Util


@pytest.mark.travis
def test_exponential_integral():
test_series = pd.Series(
data=[6., 5./3, 111./11, 45./7, 524./13],
Expand All @@ -20,7 +20,7 @@ def test_exponential_integral():

pd.testing.assert_series_equal(validation_series, output, check_less_precise=6)


@pytest.mark.travis
def test_logarithmic_integral():
test_series = pd.Series(
data=[6., 5. / 3, 111. / 11, 45. / 7, 524. / 13],
Expand All @@ -38,7 +38,7 @@ def test_logarithmic_integral():

pd.testing.assert_series_equal(validation_series, output, check_less_precise=6)


@pytest.mark.travis
def test_logistic_integral():
test_series = pd.Series(
data=[6., 5. / 3, 111. / 11, 45. / 7, 524. / 13],
Expand Down
4 changes: 2 additions & 2 deletions tests/test_psrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from fasttrips import Run


@pytest.mark.travis
def test_psrc():
"""
Test to ensure that more complex network, PSRC, is working. Also a
Expand Down Expand Up @@ -30,7 +30,7 @@ def test_psrc():
iters=1,
OVERLAP = "None",
dispersion=1.0,
test_size = 2
num_trips = 5,
)


Expand Down
Loading

0 comments on commit b4a2cfc

Please sign in to comment.