Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Aug 9, 2024
1 parent 8fc7677 commit c87049e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spatialpandas/tests/geometry/test_cx.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ def test_polygon_cx_selection(gp_polygon, rect):
assert all(expected == result)


@pytest.mark.slow
def test_polygon_cx_selection_point():
import geopandas as gpd
from shapely.geometry import shape

geometry = {"type": "Polygon", "coordinates": [[[0, 50], [20, 50], [50, 20], [50, 0]]]}
gp_multipolygon = gpd.GeoSeries([shape(geometry)])
xslice, yslice = slice(None, 0, None), slice(50, None, None)
expected = PolygonArray.from_geopandas(gp_multipolygon.cx[xslice, yslice])
result = PolygonArray.from_geopandas(gp_multipolygon).cx[xslice, yslice]
assert all(expected == result)

@pytest.mark.slow
@given(
st_multipolygon_array(min_size=1, geoseries=True),
Expand All @@ -122,6 +134,18 @@ def test_multipolygon_cx_selection(gp_multipolygon, rect):
assert all(expected == result)


@pytest.mark.slow
def test_multipolygon_cx_selection_point():
import geopandas as gpd
from shapely.geometry import shape

geometry = {"type": "MultiPolygon", "coordinates": [[[[0, 50], [20, 50], [50, 20], [50, 0]]]]}
gp_multipolygon = gpd.GeoSeries([shape(geometry)])
xslice, yslice = slice(None, 0, None), slice(50, None, None)
expected = MultiPolygonArray.from_geopandas(gp_multipolygon.cx[xslice, yslice])
result = MultiPolygonArray.from_geopandas(gp_multipolygon).cx[xslice, yslice]
assert all(expected == result)

@given(st_multipoint_array(min_size=1, geoseries=True), st_bounds(orient=True))
@hyp_settings
def test_multipoint_cx_series_selection(gp_multipoint, rect):
Expand Down

0 comments on commit c87049e

Please sign in to comment.