Skip to content

Conversation

@gauravbyte
Copy link
Contributor

Resolves: #2454
Depends on: #2230

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

Implement binary predicate relate for Geopandas with test cases

How was this patch tested?

Added tests

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

@gauravbyte gauravbyte requested a review from jiayuasu as a code owner October 26, 2025 22:31
@gauravbyte gauravbyte changed the title [GH-2231] : Implement binary predicate relate for Geopandas [GH-2454] : Implement binary predicate relate for Geopandas Oct 26, 2025
Copy link
Collaborator

@petern48 petern48 left a comment

Choose a reason for hiding this comment

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

Welcome! Thanks for working on this. It looks great. I mainly just had two minor suggestions to improve testing, but otherwise it looks good.

point = Point(0, 0)
result = s.relate(point)
expected = pd.Series(["0FFFFFFF2", "0FFFFFFF2", "FF10F0FF2"])
assert_series_equal(result.to_pandas(), expected)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert_series_equal(result.to_pandas(), expected)
self.check_pd_series_equal(result, expected)

While this works, it's actually preferred to use self.check_pd_series_equal() instead. You can read about why in this issue: #2379.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved in the commit 6f14d51

)
result = s3.relate(s4, align=True)
expected = pd.Series([None, "FF0FFF0F2", None], index=[0, 1, 2])
assert_series_equal(result.to_pandas(), expected)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert_series_equal(result.to_pandas(), expected)
self.check_pd_series_equal(result, expected)

# 4. Check that GeoDataFrame works too
df_result = s.to_geoframe().relate(s2, align=False)
expected = pd.Series(["0FFFFFFF2", "FF0FFF0F2", "1FFF0FFF2"])
assert_series_equal(df_result.to_pandas(), expected)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert_series_equal(df_result.to_pandas(), expected)
self.check_pd_series_equal(result, expected)

Comment on lines 1083 to 1084
if self.contains_any_geom_collection(geom, geom2):
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if self.contains_any_geom_collection(geom, geom2):
continue

This conditional skip is included in some test functions to work around a bug or difference in Sedona's behavior, but for this case, we can actually remove this, since the tests pass without it (I checked this branch out and tried it locally).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved in the commit Resolved in the commit 6f14d51

@petern48
Copy link
Collaborator

image

optional: I recommend setting up the pre-commit hook to auto-run the linter after each commit. It's as simple as running make checkinstall in the home directory (or running pip install pre-commit and pre-commit install). Otherwise, you'll have to remember to run pre-commit manually before submitting a PR (which I personally find easy to forget).

@gauravbyte
Copy link
Contributor Author

Thanks for the review, @petern48!
I’ve addressed your comments in 6f14d51
, rerun the tests, and set up the pre-commit hook as suggested.
Please review at your convenience.

@gauravbyte gauravbyte requested a review from petern48 October 27, 2025 09:20
Copy link
Collaborator

@petern48 petern48 left a comment

Choose a reason for hiding this comment

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

Great PR, thanks for working on it!

@jiayuasu jiayuasu merged commit df8cb1e into apache:master Oct 28, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Geopandas: Implement Binary predicate relate

3 participants