Skip to content

Commit

Permalink
Fix bug in time comparison to make sure it is elementwise
Browse files Browse the repository at this point in the history
  • Loading branch information
e-lo committed Sep 11, 2024
1 parent 4fdd29b commit 5516885
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions network_wrangler/utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,10 @@ def filter_df_to_overlapping_timespans(
mask = pd.Series([False] * len(orig_df), index=orig_df.index)
for query_timespan in query_timespans:
q_start_time, q_end_time = str_to_time_list(query_timespan)
end_time_s = orig_df["end_time"]
if orig_df["end_time"] < orig_df["start_time"]:
end_time_s += pd.Timedelta(days=1)

end_time_s = orig_df["end_time"].copy()
end_time_s[orig_df["end_time"] < orig_df["start_time"]] += pd.Timedelta(days=1)

this_ts_mask = (orig_df["start_time"] < q_end_time) & (q_start_time < end_time_s)
mask |= this_ts_mask
return orig_df.loc[mask]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_transit_io(stpaul_ex_dir, test_out_dir):

def test_transit_property_change(stpaul_ex_dir):
net = load_transit(stpaul_ex_dir)
c = stpaul_ex_dir / "project_cards" / "examples/stpaul/project_cards/transit.prop_change.route_time.yml"
c = stpaul_ex_dir / "project_cards" / "transit.prop_change.route_time.yml"
p = read_cards(c)
for p in p.values():
net.apply(p)
Expand All @@ -68,7 +68,7 @@ def test_transit_routing_change(stpaul_ex_dir):
road_net = load_roadway_from_dir(stpaul_ex_dir)
net = load_transit(stpaul_ex_dir)
net.road_net = road_net
c = stpaul_ex_dir / "project_cards" / "examples/stpaul/project_cards/transit.routing_change.yml"
c = stpaul_ex_dir / "project_cards" / "transit.routing_change.yml"
p = read_cards(c)
for p in p.values():
net.apply(p)

0 comments on commit 5516885

Please sign in to comment.