Skip to content

chore(geopandas): Make check_sgpd_equals_gpd() test for Z and M dimensions too #2513

@petern48

Description

@petern48

As discovered in this PR, it seems like check_sgpd_equals_gpd() passes when comparing geoms that only differ by Z-dimension. We need to modify the test code to test for Z and M dimensions. We'll then want to write a negative test that shows that check_sgpd_equals_gpd() fails when we expect it too. e.g comparing Point(1, 1, 3) and Point(1, 1, 4) should fail.

The code for the function is here. But the bug is probably in this call

cls.assert_geometry_almost_equal(a, e, tolerance)

The code for assert_geometry_almost_equal is here in test_base.py. This means this affects our general Python test suite as well...

Looking at that code, I would start w/ checking if equals_exact() is behaving properly. That's a shapely method. I expect it would properly return False. In that case, then the buffer + contains logic would be the part that's failing to catch the Z and M dimensions.

if not actual_geom.equals_exact(expected_geom, tolerance=tolerance):
# If the exact equals check fails, perform a buffer check with tolerance
if (
actual_geom.is_valid
and actual_geom.buffer(tolerance).contains(expected_geom)
and expected_geom.is_valid
and expected_geom.buffer(tolerance).contains(actual_geom)
):
return

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions