-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added tests for user class, multiple processes, feedback, and assignment type. - added script for running the example. - updated documentation on running the tests. - update documentation on running the example.
- Loading branch information
Showing
7 changed files
with
252 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"tests/test_assignment_type.py::test_deterministic": true, | ||
"tests/test_assignment_type.py::test_stochastic": true, | ||
"tests/test_dispersion.py::test_dispersion": true, | ||
"tests/test_fares.py::test_fares_nopf": true, | ||
"tests/test_fares.py::test_fares_nopf_nopf": true, | ||
"tests/test_feedback.py::test_fares_nopf_nopf": true, | ||
"tests/test_maxStopProcessCount.py::test_max_stop_process_count": true, | ||
"tests/test_overlap.py::test_overlap_count": true, | ||
"tests/test_overlap.py::test_overlap_count_with_split": true, | ||
"tests/test_overlap.py::test_overlap_distance": true, | ||
"tests/test_overlap.py::test_overlap_distance_with_split": true, | ||
"tests/test_overlap.py::test_overlap_none": true, | ||
"tests/test_overlap.py::test_overlap_time": true, | ||
"tests/test_overlap.py::test_overlap_time_with_split": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
|
||
from fasttrips import Run | ||
|
||
EXAMPLES_DIR = os.path.join(os.path.dirname(os.getcwd()),"Examples","test_scenario") | ||
|
||
Run.run_fasttrips( | ||
input_net_dir = os.path.join(EXAMPLES_DIR,"network"), | ||
input_demand_dir = os.path.join(EXAMPLES_DIR,"demand_reg"), | ||
run_config = os.path.join(EXAMPLES_DIR,"demand_reg","config_ft.txt"), | ||
input_weights = os.path.join(EXAMPLES_DIR,"demand_reg","pathweight_ft.txt"), | ||
output_dir = os.path.join(EXAMPLES_DIR,"output"), | ||
output_folder = "example", | ||
pathfinding_type = "stochastic", | ||
overlap_variable = "count", | ||
overlap_split_transit = True, | ||
iters = 1, | ||
dispersion = 0.50) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
import fasttrips | ||
from fasttrips import Run | ||
|
||
|
||
def test_deterministic(): | ||
|
||
EXAMPLES_DIR = os.path.join(os.getcwd(),"Examples","test_scenario") | ||
|
||
INPUT_NETWORKS = os.path.join(EXAMPLES_DIR,"network") | ||
INPUT_DEMAND = os.path.join(EXAMPLES_DIR,"demand_reg") | ||
OUTPUT_DIR = os.path.join(EXAMPLES_DIR,"output") | ||
|
||
r = Run.run_fasttrips( | ||
input_net_dir = INPUT_NETWORKS, | ||
input_demand_dir = INPUT_DEMAND, | ||
run_config = os.path.join(INPUT_DEMAND,"config_ft.txt"), | ||
input_weights = os.path.join(INPUT_DEMAND,"pathweight_ft.txt"), | ||
output_dir = OUTPUT_DIR, | ||
output_folder = "test_deterministic", | ||
pathfinding_type = "deterministic", | ||
iters = 1, | ||
dispersion = 0.50, | ||
test_size = 100) | ||
|
||
assert r["passengers_arrived"] > 0 | ||
|
||
|
||
def test_stochastic(): | ||
|
||
EXAMPLES_DIR = os.path.join(os.getcwd(),"Examples","test_scenario") | ||
|
||
INPUT_NETWORKS = os.path.join(EXAMPLES_DIR,"network") | ||
INPUT_DEMAND = os.path.join(EXAMPLES_DIR,"demand_reg") | ||
OUTPUT_DIR = os.path.join(EXAMPLES_DIR,"output") | ||
|
||
r = Run.run_fasttrips( | ||
input_net_dir = INPUT_NETWORKS, | ||
input_demand_dir = INPUT_DEMAND, | ||
run_config = os.path.join(INPUT_DEMAND,"config_ft.txt"), | ||
input_weights = os.path.join(INPUT_DEMAND,"pathweight_ft.txt"), | ||
output_dir = OUTPUT_DIR, | ||
output_folder = "test_stochastic", | ||
pathfinding_type = "stochastic", | ||
iters = 1, | ||
dispersion = 0.50, | ||
test_size = 100) | ||
|
||
assert r["passengers_arrived"] > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from fasttrips import Run | ||
|
||
|
||
def test_feedback_no_cap_const(): | ||
|
||
EXAMPLES_DIR = os.path.join(os.getcwd(),"Examples","test_scenario") | ||
|
||
INPUT_NETWORKS = os.path.join(EXAMPLES_DIR,"network") | ||
INPUT_DEMAND = os.path.join(EXAMPLES_DIR,"demand_reg") | ||
OUTPUT_DIR = os.path.join(EXAMPLES_DIR,"output") | ||
|
||
r = Run.run_fasttrips( | ||
input_net_dir = INPUT_NETWORKS, | ||
input_demand_dir = INPUT_DEMAND, | ||
run_config = os.path.join(INPUT_DEMAND,"config_ft.txt"), | ||
input_weights = os.path.join(INPUT_DEMAND,"pathweight_ft.txt"), | ||
output_dir = OUTPUT_DIR, | ||
output_folder = "test_feedback_no_cap_const", | ||
pathfinding_type = "stochastic", | ||
capacity = False, | ||
iters = 3, | ||
dispersion = 0.50) | ||
|
||
assert r["passengers_arrived"] > 0 | ||
|
||
def test_feedback_with_cap_const(): | ||
|
||
EXAMPLES_DIR = os.path.join(os.getcwd(),"Examples","test_scenario") | ||
|
||
INPUT_NETWORKS = os.path.join(EXAMPLES_DIR,"network") | ||
INPUT_DEMAND = os.path.join(EXAMPLES_DIR,"demand_reg") | ||
OUTPUT_DIR = os.path.join(EXAMPLES_DIR,"output") | ||
|
||
r = Run.run_fasttrips( | ||
input_net_dir = INPUT_NETWORKS, | ||
input_demand_dir = INPUT_DEMAND, | ||
run_config = os.path.join(INPUT_DEMAND,"config_ft.txt"), | ||
input_weights = os.path.join(INPUT_DEMAND,"pathweight_ft.txt"), | ||
output_dir = OUTPUT_DIR, | ||
output_folder = "test_feedback_with_cap_const", | ||
pathfinding_type = "stochastic", | ||
capacity = True, | ||
iters = 3, | ||
dispersion = 0.50) | ||
|
||
assert r["passengers_arrived"] > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
import fasttrips | ||
from fasttrips import Run | ||
|
||
|
||
def test_multiple_processes(): | ||
|
||
EXAMPLES_DIR = os.path.join(os.getcwd(),"Examples","test_scenario") | ||
|
||
INPUT_NETWORKS = os.path.join(EXAMPLES_DIR,"network") | ||
INPUT_DEMAND = os.path.join(EXAMPLES_DIR,"demand_reg") | ||
OUTPUT_DIR = os.path.join(EXAMPLES_DIR,"output") | ||
|
||
r = Run.run_fasttrips( | ||
input_net_dir = INPUT_NETWORKS, | ||
input_demand_dir = INPUT_DEMAND, | ||
run_config = os.path.join(INPUT_DEMAND,"config_ft.txt"), | ||
input_weights = os.path.join(INPUT_DEMAND,"pathweight_ft.txt"), | ||
output_dir = OUTPUT_DIR, | ||
output_folder = "test_2processes", | ||
pathfinding_type = "stochastic", | ||
number_of_processes = 2, | ||
iters = 1, | ||
dispersion = 0.50 ) | ||
|
||
assert r["passengers_arrived"] > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
import fasttrips | ||
from fasttrips import Run | ||
|
||
|
||
def test_user_classes(): | ||
|
||
EXAMPLES_DIR = os.path.join(os.getcwd(),"Examples","test_scenario") | ||
|
||
INPUT_NETWORKS = os.path.join(EXAMPLES_DIR,"network") | ||
INPUT_DEMAND = os.path.join(EXAMPLES_DIR,"demand_twopaths") | ||
OUTPUT_DIR = os.path.join(EXAMPLES_DIR,"output") | ||
|
||
r = Run.run_fasttrips( | ||
input_net_dir = INPUT_NETWORKS, | ||
input_demand_dir = INPUT_DEMAND, | ||
run_config = os.path.join(INPUT_DEMAND,"config_ft.txt"), | ||
input_weights = os.path.join(INPUT_DEMAND,"pathweight_ft.txt"), | ||
input_functions = os.path.join(INPUT_DEMAND,"config_ft.py"), | ||
output_dir = OUTPUT_DIR, | ||
output_folder = "test_userclasses", | ||
pathfinding_type = "stochastic", | ||
iters = 1, | ||
dispersion = 0.50, | ||
test_size = 100) | ||
|
||
assert r["passengers_arrived"] > 0 | ||
|
2451df9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test fails because of this: pytest-dev/pytest#958
2451df9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AHA. And that is why things started passing when I removed the multiple processes command from the input networks. I'll delete this test for now then.
2451df9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does run successfully if you do it via
python -m pytest