-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first round
geometry.voronoi_skeleton()
tests (#27)
* first round voronoi_skeleton() tests * gpd leq 1 testing polygonize * bumpy min geopandas=0.14 * update min reqs & pin all in oldest CI * update min reqs & pin all in oldest CI [2] * break out _remove_sliver() func + test * add codecov - update README * break out _as_parts() func + test * break out _consolidate() func + test * remove unused internal func in conftest.polygonize() * update geom testing helper * rmeove spacing * doctring for max_segment_length * .buffer(0) not needed for certain scenarios in polygonize() conftest
- Loading branch information
Showing
6 changed files
with
256 additions
and
35 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,22 @@ | ||
codecov: | ||
notify: | ||
after_n_builds: 6 | ||
coverage: | ||
range: 50..95 | ||
round: nearest | ||
precision: 1 | ||
status: | ||
project: | ||
default: | ||
threshold: 2% | ||
patch: | ||
default: | ||
threshold: 2% | ||
target: 80% | ||
ignore: | ||
- "tests/*" | ||
comment: | ||
layout: "reach, diff, files" | ||
behavior: once | ||
after_n_builds: 6 | ||
require_changes: true |
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,66 @@ | ||
import geopandas.testing | ||
import numpy | ||
import pandas | ||
import pytest | ||
import shapely | ||
|
||
line_collection = ( | ||
list[shapely.LineString] | ||
| tuple[shapely.LineString] | ||
| numpy.ndarray | ||
| pandas.Series | ||
| geopandas.GeoSeries | ||
) | ||
|
||
geometry_collection = ( | ||
list[shapely.GeometryCollection] | ||
| tuple[shapely.GeometryCollection] | ||
| numpy.ndarray | ||
| pandas.Series | ||
| geopandas.GeoSeries | ||
) | ||
|
||
|
||
def polygonize( | ||
collection: line_collection, as_geom: bool = True | ||
) -> shapely.Polygon | geopandas.GeoSeries: | ||
"""Testing helper -- Create polygon from collection of lines.""" | ||
if isinstance(collection, pandas.Series | geopandas.GeoSeries): | ||
_poly = geopandas.GeoSeries(collection).polygonize() | ||
if as_geom: | ||
return _poly.squeeze() | ||
else: | ||
return _poly | ||
else: | ||
return shapely.polygonize(collection).buffer(0) | ||
|
||
|
||
def is_geopandas(collection: geometry_collection) -> bool: | ||
return isinstance(collection, geopandas.GeoSeries | geopandas.GeoDataFrame) | ||
|
||
|
||
def geom_test( | ||
collection1: geometry_collection, | ||
collection2: geometry_collection, | ||
tolerance: float = 1e-1, | ||
) -> bool: | ||
"""Testing helper -- geometry verification.""" | ||
|
||
if not is_geopandas(collection1): | ||
collection1 = geopandas.GeoSeries(collection1) | ||
|
||
if not is_geopandas(collection2): | ||
collection2 = geopandas.GeoSeries(collection2) | ||
|
||
assert shapely.equals_exact( | ||
collection1.geometry.normalize(), | ||
collection2.geometry.normalize(), | ||
tolerance=tolerance, | ||
).all() | ||
|
||
|
||
def pytest_configure(config): # noqa: ARG001 | ||
"""PyTest session attributes, methods, etc.""" | ||
|
||
pytest.polygonize = polygonize | ||
pytest.geom_test = geom_test |
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