-
Notifications
You must be signed in to change notification settings - Fork 742
[GH-2450] chore(geopandas): write sjoin match tests for dwithin() #2466
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
Open
bunnysocks
wants to merge
2
commits into
apache:master
Choose a base branch
from
bunnysocks:chore/sjoin-match-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import pytest | ||
| import geopandas as gpd | ||
| from shapely.geometry import Point | ||
| from sedona.geopandas import sjoin | ||
| from geopandas.tools import sjoin as gpd_sjoin | ||
| from geopandas import GeoDataFrame | ||
|
|
||
| class TestSJoinDWithinMatch: | ||
| def setup_method(self): | ||
| # Create test GeoDataFrames | ||
| self.gdf1 = gpd.GeoDataFrame( | ||
| {"id": [1, 2, 3]}, | ||
| geometry=[Point(0, 0), Point(1, 1), Point(2, 2)], | ||
| crs="EPSG:4326" | ||
| ) | ||
| self.gdf2 = gpd.GeoDataFrame( | ||
| {"id": ["a", "b", "c"]}, | ||
| geometry=[Point(0.1, 0.1), Point(1.5, 1.5), Point(10, 10)], | ||
| crs="EPSG:4326" | ||
| ) | ||
|
|
||
| def test_dwithin_equivalence(self): | ||
| """Ensure Sedona and GeoPandas produce same results for dwithin() join.""" | ||
| distance = 0.3 | ||
|
|
||
| # Sedona join | ||
| sedona_result = sjoin(self.gdf1, self.gdf2, predicate="dwithin", distance=distance) | ||
| # GeoPandas join | ||
| gpd_result = gpd_sjoin(self.gdf1, self.gdf2, predicate="dwithin", distance=distance) | ||
|
|
||
| assert isinstance(sedona_result, GeoDataFrame) | ||
| assert isinstance(gpd_result, GeoDataFrame) | ||
|
|
||
| # Sort and compare IDs | ||
| sedona_pairs = set(zip(sedona_result["id_left"], sedona_result["id_right"])) | ||
| gpd_pairs = set(zip(gpd_result["id_left"], gpd_result["id_right"])) | ||
| assert sedona_pairs == gpd_pairs | ||
|
|
||
| def test_dwithin_small_distance(self): | ||
| """Ensure small distance returns fewer or no matches.""" | ||
| small_distance = 0.01 | ||
| sedona_small = sjoin(self.gdf1, self.gdf2, predicate="dwithin", distance=small_distance) | ||
| assert len(sedona_small) <= 1 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried running this locally and found that there are also multiple issues with this test code (more than just this), that prevent it from running properly. Simple things like data types issues. @bunnysocks Do you need help with setting up your developer environment? You can follow these directions for setting it up, so you can test locally. Getting it working by following those instructions should work pretty smoothly. The logic this PR proposes is on the right track, but it will be very helpful for you to run the tests locally to avoid simple errors. Feel free to ping if you get stuck or need help, including with dev env setup.
e.g failed CI run
https://github.com/apache/sedona/actions/runs/18967529015/job/54243890091?pr=2466