Skip to content

[GH-3084] Align GeoPandas test comparison by index (results are unordered)#3085

Merged
jiayuasu merged 1 commit into
masterfrom
fix-geopandas-comparison-ordering
Jun 26, 2026
Merged

[GH-3084] Align GeoPandas test comparison by index (results are unordered)#3085
jiayuasu merged 1 commit into
masterfrom
fix-geopandas-comparison-ordering

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Yes

Is this PR related to a ticket?

Yes, resolves #3084

What changes were proposed in this PR?

check_sgpd_equals_gpd in python/tests/geopandas/test_geopandas_base.py compared the actual GeoSeries against the expected gpd.GeoSeries element-wise by position and asserted index equality positionally. This assumed the result preserved input row order.

Sedona's GeoPandas API does not guarantee result row ordering, so operations that shuffle across Spark partitions (e.g. GeoSeries.clip_by_rect) can return rows in a different order, causing false test failures (test_clip_by_rect reports POLYGON EMPTY vs the expected clipped polygon even though all values are correct).

This PR aligns both sides by index before comparing, making the helper order-agnostic. It is a no-op for operations that already return ordered results.

How was this patch tested?

Ran test_clip_by_rect (both test_geoseries.py and test_match_geopandas_series.py) and test_buffer with a multi-partition local Spark (local[*]); all pass with the fix and the previously-failing clip_by_rect cases now compare correctly.

Did this PR include necessary documentation updates?

No, this is a test-only change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the shared GeoPandas test helper to avoid false negatives when Sedona operations return results in a non-deterministic row order (e.g., due to Spark partition shuffles), by aligning comparisons on index rather than position.

Changes:

  • Sort both actual (to_geopandas()) and expected GeoSeries by index before element-wise comparison.
  • Update index equality assertion to compare the aligned (sorted) indices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jiayuasu jiayuasu merged commit a0a159c into master Jun 26, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoPandas test check_sgpd_equals_gpd assumes result ordering that the API does not guarantee

2 participants