Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make polygon fixture data valid #1472

Merged
merged 14 commits into from
Oct 17, 2024
90 changes: 46 additions & 44 deletions python/cuspatial/cuspatial/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,40 @@ def gs():
g6 = MultiLineString((((23, 24), (25, 26)), ((27, 28), (29, 30))))
g7 = LineString(((31, 32), (33, 34)))
g8 = Polygon(
((35, 36), (37, 38), (39, 40), (41, 42)),
((35, 36), (38, 36), (41, 39), (41, 42)),
)
# TODO: g9, g10, g11 are invalid
# https://github.com/libgeos/geos/issues/1177
g9 = MultiPolygon(
[
(
((43, 44), (45, 46), (47, 48)),
[((49, 50), (51, 52), (53, 54))],
((43, 44), (48, 44), (47, 48)),
[((45, 45), (46, 46), (47, 45))],
),
(
((55, 56), (57, 58), (59, 60)),
[((61, 62), (63, 64), (65, 66))],
((55, 56), (60, 56), (59, 60)),
[((57, 57), (58, 58), (59, 57))],
),
]
)
g10 = MultiPolygon(
[
(
((67, 68), (69, 70), (71, 72)),
[((73, 74), (75, 76), (77, 78))],
((67, 68), (72, 68), (71, 72)),
[((69, 69), (70, 70), (71, 69))],
),
(
((79, 80), (81, 82), (83, 84)),
((79, 80), (90, 82), (83, 90)),
[
((85, 86), (87, 88), (89, 90)),
((91, 92), (93, 94), (95, 96)),
((80, 81), (82, 84), (84, 82)),
((85, 85), (88, 82), (86, 82)),
],
),
]
)
g11 = Polygon(
((97, 98), (99, 101), (102, 103), (101, 108)),
[((106, 107), (108, 109), (110, 111), (113, 108))],
[((99, 102), (100, 103), (101, 103), (100, 102))],
)
gs = gpd.GeoSeries([g0, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11])
return gs
Expand All @@ -72,8 +72,10 @@ def gpdf(gs):
random_col = int_col
np.random.shuffle(random_col)
str_col = [str(x) for x in int_col]
key_col = np.repeat(np.arange(4), len(int_col) // 4)
key_col = np.repeat(np.arange(4), (len(int_col) // 4) + 1)
key_col = key_col[: len(int_col)]
np.random.shuffle(key_col)

result = gpd.GeoDataFrame(
{
"geometry": gs,
Expand All @@ -92,56 +94,56 @@ def polys():
return np.array(
(
(35, 36),
(37, 38),
(39, 40),
(38, 36),
(41, 39),
harrism marked this conversation as resolved.
Show resolved Hide resolved
(41, 42),
(35, 36),
(43, 44),
(45, 46),
(48, 44),
(47, 48),
(43, 44),
(49, 50),
(51, 52),
(53, 54),
(49, 50),
(45, 45),
(46, 46),
(47, 45),
(45, 45),
(55, 56),
(57, 58),
(60, 56),
(59, 60),
(55, 56),
(61, 62),
(63, 64),
(65, 66),
(61, 62),
(57, 57),
(58, 58),
(59, 57),
(57, 57),
(67, 68),
(69, 70),
(72, 68),
(71, 72),
(67, 68),
(73, 74),
(75, 76),
(77, 78),
(73, 74),
(69, 69),
(70, 70),
(71, 69),
(69, 69),
(79, 80),
(81, 82),
(83, 84),
(90, 82),
(83, 90),
(79, 80),
(85, 86),
(87, 88),
(89, 90),
(85, 86),
(91, 92),
(93, 94),
(95, 96),
(91, 92),
(80, 81),
(82, 84),
(84, 82),
(80, 81),
(85, 85),
(88, 82),
(86, 82),
(85, 85),
(97, 98),
(99, 101),
(102, 103),
(101, 108),
(97, 98),
(106, 107),
(108, 109),
(110, 111),
(113, 108),
(106, 107),
(99, 102),
(100, 103),
(101, 103),
(100, 102),
(99, 102),
)
)

Expand Down
9 changes: 0 additions & 9 deletions python/cuspatial/cuspatial/tests/test_cudf_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
import geopandas as gpd
import numpy as np
import pandas as pd
import pytest

import cuspatial

reason = (
"gs fixture contains invalid Polygons/MultiPolygons: "
"https://github.com/libgeos/geos/issues/1177"
)


@pytest.mark.xfail(reason=reason)
def test_sort_index_series(gs):
gs.index = np.random.permutation(len(gs))
cugs = cuspatial.from_geopandas(gs)
Expand All @@ -21,7 +14,6 @@ def test_sort_index_series(gs):
gpd.testing.assert_geoseries_equal(got, expected)


@pytest.mark.xfail(reason=reason)
def test_sort_index_dataframe(gpdf):
gpdf.index = np.random.permutation(len(gpdf))
cugpdf = cuspatial.from_geopandas(gpdf)
Expand All @@ -30,7 +22,6 @@ def test_sort_index_dataframe(gpdf):
gpd.testing.assert_geodataframe_equal(got, expected)


@pytest.mark.xfail(reason=reason)
def test_sort_values(gpdf):
cugpdf = cuspatial.from_geopandas(gpdf)
expected = gpdf.sort_values("random")
Expand Down
11 changes: 2 additions & 9 deletions python/cuspatial/cuspatial/tests/test_from_geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@ def test_dataframe_column_access(gs):

def test_from_geoseries_complex(gs):
cugs = cuspatial.from_geopandas(gs)
assert cugs.points.xy.sum() == 18
assert cugs.lines.xy.sum() == 540
assert cugs.multipoints.xy.sum() == 36
assert cugs.polygons.xy.sum() == 7436
assert cugs._column.polygons._column.base_children[0].sum() == 15
assert (
cugs._column.polygons._column.base_children[1].base_children[0].sum()
== 38
)
gs_roundtrip = cugs.to_geopandas()
gpd.testing.assert_geoseries_equal(gs_roundtrip, gs)


def test_from_geopandas_point():
Expand Down
Loading
Loading