-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Graph tests, updates to summarizer functions (#11)
* clean up masks * parameterize the walk speed * more tests on the edges of the graph * typing everywhere * add some comments, drop out a dataframe append loop * add some comments, drop out a dataframe append loop * add typehints * graph empty create test * graph empty create test * drop tuples on list extend * add check about list lengths * add test to check summary edge output, comments
- Loading branch information
Showing
2 changed files
with
90 additions
and
24 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
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 |
---|---|---|
@@ -1 +1,38 @@ | ||
import pytest | ||
import os | ||
|
||
from peartree.graph import (generate_empty_md_graph, | ||
generate_summary_graph_elements) | ||
from peartree.paths import get_representative_feed | ||
|
||
|
||
def fixture(filename): | ||
return os.path.join(os.path.dirname(__file__), 'fixtures', filename) | ||
|
||
|
||
def test_generate_empty_graph(): | ||
G = generate_empty_md_graph('foo') | ||
assert len(G.edges()) == 0 | ||
assert len(G.nodes()) == 0 | ||
|
||
|
||
def test_generate_summary_graph_elements(): | ||
path_1 = fixture('caltrain-2017-07-24.zip') | ||
feed_1 = get_representative_feed(path_1) | ||
|
||
start = 7 * 60 * 60 | ||
end = 10 * 60 * 60 | ||
|
||
(summary_edge_costs, | ||
wait_times_by_stop) = generate_summary_graph_elements(feed_1, start, end) | ||
|
||
# Ensure that the summary edge cost dataframe looks as it should | ||
ec_cols = ['edge_cost', 'from_stop_id', 'to_stop_id'] | ||
for c in ec_cols: | ||
assert c in summary_edge_costs.columns | ||
|
||
# Make sure that all edges are unique - there are no duplicated | ||
# in the returned edge dataframe (each should be its own summary) | ||
f = summary_edge_costs.from_stop_id | ||
t = summary_edge_costs.to_stop_id | ||
z = list(zip(f, t)) | ||
assert len(list(set(z))) == len(z) |