Skip to content

Commit

Permalink
finalized isochrones tests
Browse files Browse the repository at this point in the history
  • Loading branch information
culebron committed Aug 29, 2021
1 parent 7e7b8ed commit 2d52ce9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion erde/op/isochrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def main(sources: gpd.GeoDataFrame, router, durations, speed:float, grid_density
durations = list(durations) # converting iterable to list

from tqdm.auto import tqdm
idx = 0
for i, r in tqdm(sources.iterrows(), desc='Isochrones', total=len(sources), disable=not pbar):
r2 = r.to_dict()
ir = IsochroneRouter(
Expand All @@ -301,4 +302,8 @@ def main(sources: gpd.GeoDataFrame, router, durations, speed:float, grid_density
ir.grid_density = r2.get(grid_density, grid_density)
ir.max_snap = r2.get(max_snap, max_snap)
ir.mts = r2.get(mts, mts)
yield ir.polygons
gdf = ir.polygons
gdf['source'] = i
gdf.index = pd.RangeIndex(idx, idx + len(gdf))
idx += len(gdf)
yield gdf
12 changes: 11 additions & 1 deletion tests/isochrone/test_ic.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ def test_string_params():
for k, v in extra_params.items():
s2[k] = (v * len(s2))[:len(s2)]

with _patch_table_route():
assert len(s2.mts.unique()) > 1
assert len(s2.router.unique()) > 1

with _patch_table_route() as m:
resp = pd.concat(ic.main(s2, **{k: k for k in extra_params.keys()}))
print(resp)

for args, row in zip(m.call_args_list, s2.to_dict(orient='records')):
ar, kw = args

assert ar[0][0] == row['geometry']
assert ar[2] == row['router']
assert kw['max_table_size'] == row['mts']

0 comments on commit 2d52ce9

Please sign in to comment.