Skip to content

Commit

Permalink
fix: update _summarise_core() in MGTFS to return correct results; cho…
Browse files Browse the repository at this point in the history
…re: update tests (#233)
  • Loading branch information
CBROWN-ONS authored Jan 17, 2024
1 parent 42e6dd1 commit aa98494
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/transport_performance/gtfs/multi_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ def _summarise_core(
if not return_summary:
return daily_schedule
if not to_days:
dated = daily_schedule[["date", "route_type", group_col]]
dated = daily_schedule[
["date", "route_type", group_col]
].drop_duplicates()
dated = dated.groupby(["date", "route_type"]).count().reset_index()
dated = dated.rename(columns={group_col: count_col})
dated = dated.sort_values("date")
Expand Down
5 changes: 2 additions & 3 deletions tests/gtfs/test_multi_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def test__summarise_core(self, multi_gtfs_fixture):
{
"date": ["2023-06-06", "2023-06-06"],
"route_type": [3, 200],
"route_count": [151, 25],
"route_count": [12, 4],
},
index=[2, 3],
)
Expand Down Expand Up @@ -368,8 +368,7 @@ def test__summarise_core(self, multi_gtfs_fixture):
)
assert len(dated_sum) == 590, "Dated route counts not as expected"
assert (
dated_sum[dated_sum.date == "2024-04-06"].route_count.iloc[0]
== 159
dated_sum[dated_sum.date == "2024-04-06"].route_count.iloc[0] == 9
), "Unexpecteed number of routes on 2024-04-06"

def test_summarise_trips(self, multi_gtfs_fixture):
Expand Down

0 comments on commit aa98494

Please sign in to comment.