chay0112 commented on code in PR #2512:
URL: https://github.com/apache/sedona/pull/2512#discussion_r2582341661
##########
python/tests/geopandas/test_match_geopandas_series.py:
##########
@@ -878,7 +878,48 @@ def test_force_2d(self):
self.check_sgpd_equals_gpd(sgpd_3d, gpd_3d)
def test_force_3d(self):
- pass
+ # force_3d was added from geopandas 1.0.0
+ if parse_version(gpd.__version__) < parse_version("1.0.0"):
+ pytest.skip("geopandas force_3d requires version 1.0.0 or higher")
+ # 1) Promote 2D to 3D with z = 4
+ for geom in self.geoms:
+ if isinstance(geom[0], (LinearRing, GeometryCollection,
MultiPolygon)):
Review Comment:
Hi Peter, Thanks for your suggestions.
I believe if we remove Multipolygon and GeometryCollections the test would
still fail for geoms, something like below
`
FAILED
==============================================================================
FAILURES
==============================================================================
_______________________________________________________________
TestMatchGeopandasSeries.test_force_3d
_______________________________________________________________
self = <tests.geopandas.test_match_geopandas_series.TestMatchGeopandasSeries
object at 0x154827250>
def test_force_3d(self):
# force_3d was added from geopandas 1.0.0
if parse_version(gpd.__version__) < parse_version("1.0.0"):
pytest.skip("geopandas force_3d requires version 1.0.0 or
higher")
# 1) Promote 2D to 3D with z = 4
for geom in self.geoms:
if isinstance(geom[0], (LinearRing)):
continue
sgpd_result = GeoSeries(geom).force_3d(4)
gpd_result = gpd.GeoSeries(geom).force_3d(4)
> self.check_sgpd_equals_gpd(sgpd_result, gpd_result)
python/tests/geopandas/test_match_geopandas_series.py:890:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _
python/tests/geopandas/test_geopandas_base.py:70: in check_sgpd_equals_gpd
cls.assert_geometry_almost_equal(a, e, tolerance)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _
cls = <class
'tests.geopandas.test_match_geopandas_series.TestMatchGeopandasSeries'>
left_geom = <POLYGON Z ((0 0 4, 0 1 4, 1 0 4, 0 0 4), (0.1 0.1 4, 0.1 0.2 4,
0.2 0.1 4, ...>
right_geom = <MULTIPOLYGON Z (((0 0 4, 0 1 4, 1 0 4, 0 0 4), (0.1 0.1 4, 0.1
0.2 4, 0.2 0...>, tolerance = 0.01
@classmethod
def assert_geometry_almost_equal(
cls,
left_geom: Union[str, BaseGeometry],
right_geom: Union[str, BaseGeometry],
tolerance=1e-6,
):
"""
Assert that two geometries are almost equal.
Note: this function will only check Z and M dimensions for shapely
>= 2.1.0 (python >= 3.10)
When comparing geometries with Z or M dimensions, this function will
ignore `tolerance` and check for exact equality.
"""
expected_geom = (
wkt.loads(left_geom) if isinstance(left_geom, str) else left_geom
)
actual_geom = (
wkt.loads(right_geom) if isinstance(right_geom, str) else
right_geom
)
# Note: only shapely >= 2.1.0 supports Z and M dimensions
# If has Z or M dimension, use equals_identical to check the equality
if SHAPELY_GE_210 and (has_zm(actual_geom) or has_zm(expected_geom)):
if not shapely.equals_identical(actual_geom, expected_geom):
> raise ValueError(
f"Geometry equality check failed for {left_geom} and
{right_geom}"
)
E ValueError: Geometry equality check failed for POLYGON Z ((0
0 4, 0 1 4, 1 0 4, 0 0 4), (0.1 0.1 4, 0.1 0.2 4, 0.2 0.1 4, 0.1 0.1 4)) and
MULTIPOLYGON Z (((0 0 4, 0 1 4, 1 0 4, 0 0 4), (0.1 0.1 4, 0.1 0.2 4, 0.2 0.1
4, 0.1 0.1 4)))
python/tests/test_base.py:146: ValueError
==========================================================================
warnings summary
==========================================================================
`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]