Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
internaut committed Feb 3, 2021
1 parent 06b4e75 commit fad86de
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 126 deletions.
4 changes: 2 additions & 2 deletions examples/duplicate_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import numpy as np
import geopandas as gpd

from geovoronoi import coords_to_points, points_to_coords, voronoi_regions_from_coords, get_points_to_poly_assignments
from geovoronoi import coords_to_points, points_to_coords, voronoi_regions_from_coords, points_to_region
from geovoronoi.plotting import subplot_for_map, plot_voronoi_polys_with_points_in_area


Expand Down Expand Up @@ -82,7 +82,7 @@
print('> voronoi region', i_poly, '-> points', str(pt_indices))

print('\n\npoints to voronoi region assignments:')
pts_to_poly_assignments = get_points_to_poly_assignments(poly_to_pt_assignments)
pts_to_poly_assignments = points_to_region(poly_to_pt_assignments)
for i_pt, i_poly in pts_to_poly_assignments.items():
print('> point ', i_pt, '-> voronoi region', i_poly)

Expand Down
2 changes: 1 addition & 1 deletion geovoronoi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


from ._voronoi import (coords_to_points, points_to_coords, voronoi_regions_from_coords,
get_points_to_poly_assignments)
points_to_region)
from ._geom import calculate_polygon_areas, line_segment_intersection


Expand Down
177 changes: 134 additions & 43 deletions geovoronoi/_voronoi.py

Large diffs are not rendered by default.

227 changes: 152 additions & 75 deletions geovoronoi/plotting.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions tests/_testtools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Set of utility functions for testing.
Author: Markus Konrad <markus.konrad@wzb.eu>
"""

from functools import partial

import numpy as np
Expand Down
6 changes: 6 additions & 0 deletions tests/test_geom.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Tests for the private _geom module.
Author: Markus Konrad <markus.konrad@wzb.eu>
"""

import pytest
import numpy as np

Expand Down
16 changes: 11 additions & 5 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Tests for the main module.
Author: Markus Konrad <markus.konrad@wzb.eu>
"""

import numpy as np
import geopandas as gpd
from shapely.geometry import Polygon, MultiPolygon, asPoint
Expand All @@ -9,7 +15,7 @@
from ._testtools import coords_2d_array
from geovoronoi import (
voronoi_regions_from_coords, coords_to_points, points_to_coords, calculate_polygon_areas,
get_points_to_poly_assignments
points_to_region
)
from geovoronoi.plotting import subplot_for_map, plot_voronoi_polys_with_points_in_area

Expand All @@ -35,9 +41,9 @@ def test_coords_to_points_and_points_to_coords(coords):
def test_get_points_to_poly_assignments(poly_to_pts, expected):
if expected is None:
with pytest.raises(ValueError):
get_points_to_poly_assignments(poly_to_pts)
points_to_region(poly_to_pts)
else:
assert get_points_to_poly_assignments(poly_to_pts) == expected
assert points_to_region(poly_to_pts) == expected


@given(available_points=st.permutations(list(range(10))), n_poly=st.integers(0, 10))
Expand All @@ -64,7 +70,7 @@ def test_get_points_to_poly_assignments_hypothesis(available_points, n_poly):
if n_poly > 0:
assert set(sum(list(poly_to_pts.values()), [])) == set(available_points)

pts_to_poly = get_points_to_poly_assignments(poly_to_pts)
pts_to_poly = points_to_region(poly_to_pts)

assert isinstance(pts_to_poly, dict)

Expand Down Expand Up @@ -154,7 +160,7 @@ def test_voronoi_regions_from_coords_italy(n_pts, per_geom, return_unassigned_pt
assert len(region_pts) == len(region_polys)

# points to region assignments
pts_region = get_points_to_poly_assignments(region_pts)
pts_region = points_to_region(region_pts)
if unassigned_pts is not None: # check that unassigned points are not in the result set
assert set(range(n_pts)) - set(pts_region.keys()) == unassigned_pts

Expand Down

0 comments on commit fad86de

Please sign in to comment.