-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not prune trips with just one arrival time (#143)
* break out mask var name * Overwrite one null val stop wait times with fallback * New test to ensure that 1 row stops are passed through * Drop excess logic
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import numpy as np | ||
import pandas as pd | ||
from peartree.summarizer import generate_summary_wait_times | ||
|
||
|
||
def test_generate_summary_wait_times(): | ||
df = pd.DataFrame({ | ||
'stop_id': [ | ||
1, | ||
1, | ||
2, | ||
2, | ||
3, | ||
4], | ||
'wait_dir_0': [ | ||
10, | ||
10, | ||
19, | ||
21, | ||
np.nan, | ||
12], | ||
'wait_dir_1': [ | ||
np.nan, | ||
np.nan, | ||
9, | ||
11, | ||
np.nan, | ||
np.nan], | ||
}) | ||
|
||
fallback_stop_cost = 40.0 # seconds | ||
res = generate_summary_wait_times(df, fallback_stop_cost) | ||
res = res.sort_values(by='stop_id') | ||
assert res['stop_id'].tolist() == [1, 2, 3, 4] | ||
assert res['avg_cost'].tolist() == [10.0, 15.0, 40.0, 12.0] |