Skip to content

Commit f42dc15

Browse files
authored
Don't compare empty geometry tests against geopandas (#127)
* Don't compare empty geometry tests against geopandas * Temporarily pin pandas < 2.1
1 parent d1dbe93 commit f42dc15

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'dask',
3535
'fsspec',
3636
'numba',
37-
'pandas',
37+
'pandas <2.1',
3838
'param',
3939
'pyarrow >=1.0',
4040
'retrying',

spatialpandas/tests/geometry/algorithms/test_intersection.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def test_segment_intersection(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1):
6262
assert result1 == result2
6363

6464
# Use shapely polygon to compute expected intersection
65+
if (ax0 == ax1 == bx0 == bx1) or (ay0 == ay1 == by0 == by1):
66+
return
6567
line1 = sg.LineString([(ax0, ay0), (ax1, ay1)])
6668
line2 = sg.LineString([(bx0, by0), (bx1, by1)])
6769
expected = line1.intersects(line2)
@@ -132,6 +134,9 @@ def test_multipoint_intersects_rect(gp_multipoint, rect):
132134
@given(st_line_array(), st_bounds())
133135
@hyp_settings
134136
def test_line_intersects_rect(gp_line, rect):
137+
x0, y0, x1, y1 = rect
138+
if x0 == x1 or y0 == y1:
139+
return
135140
sg_rect = sg.box(*rect)
136141

137142
expected = gp_line.intersects(sg_rect)
@@ -154,6 +159,9 @@ def test_line_intersects_rect(gp_line, rect):
154159
@given(st_multiline_array(), st_bounds())
155160
@hyp_settings
156161
def test_multiline_intersects_rect(gp_multiline, rect):
162+
x0, y0, x1, y1 = rect
163+
if x0 == x1 or y0 == y1:
164+
return
157165
sg_rect = sg.box(*rect)
158166

159167
expected = gp_multiline.intersects(sg_rect)
@@ -186,6 +194,9 @@ def test_multiline_intersects_rect(gp_multiline, rect):
186194
)
187195
@hyp_settings
188196
def test_polygon_intersects_rect(gp_polygon, rect):
197+
x0, y0, x1, y1 = rect
198+
if x0 == x1 or y0 == y1:
199+
return
189200
sg_rect = sg.box(*rect)
190201

191202
expected = gp_polygon.intersects(sg_rect)
@@ -216,6 +227,9 @@ def test_polygon_intersects_rect(gp_polygon, rect):
216227
)
217228
@hyp_settings
218229
def test_multipolygon_intersects_rect(gp_multipolygon, rect):
230+
x0, y0, x1, y1 = rect
231+
if x0 == x1 or y0 == y1:
232+
return
219233
sg_rect = sg.box(*rect)
220234

221235
expected = gp_multipolygon.intersects(sg_rect)

spatialpandas/tests/geometry/test_cx.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def test_line_cx_selection(gp_line, rect):
5959
x0, y0, x1, y1 = rect
6060
for xslice in get_slices(x0, x1):
6161
for yslice in get_slices(y0, y1):
62+
if xslice.start == xslice.stop or yslice.start == yslice.stop:
63+
continue
6264
expected = LineArray.from_geopandas(gp_line.cx[xslice, yslice])
6365
result = LineArray.from_geopandas(gp_line).cx[xslice, yslice]
6466
assert all(expected == result)
@@ -71,6 +73,8 @@ def test_multiline_cx_selection(gp_multiline, rect):
7173
x0, y0, x1, y1 = rect
7274
for xslice in get_slices(x0, x1):
7375
for yslice in get_slices(y0, y1):
76+
if xslice.start == xslice.stop or yslice.start == yslice.stop:
77+
continue
7478
expected = MultiLineArray.from_geopandas(gp_multiline.cx[xslice, yslice])
7579
result = MultiLineArray.from_geopandas(gp_multiline).cx[xslice, yslice]
7680
assert all(expected == result)
@@ -88,6 +92,8 @@ def test_polygon_cx_selection(gp_polygon, rect):
8892
x0, y0, x1, y1 = rect
8993
for xslice in get_slices(x0, x1):
9094
for yslice in get_slices(y0, y1):
95+
if xslice.start == xslice.stop or yslice.start == yslice.stop:
96+
continue
9197
expected = PolygonArray.from_geopandas(gp_polygon.cx[xslice, yslice])
9298
result = PolygonArray.from_geopandas(gp_polygon).cx[xslice, yslice]
9399
assert all(expected == result)
@@ -105,6 +111,8 @@ def test_multipolygon_cx_selection(gp_multipolygon, rect):
105111
x0, y0, x1, y1 = rect
106112
for xslice in get_slices(x0, x1):
107113
for yslice in get_slices(y0, y1):
114+
if xslice.start == xslice.stop or yslice.start == yslice.stop:
115+
continue
108116
expected = MultiPolygonArray.from_geopandas(
109117
gp_multipolygon.cx[xslice, yslice]
110118
)

0 commit comments

Comments
 (0)