Add regression test for read_file GeoDataFrame return type (#1186)#1339
Open
vickysharma-prog wants to merge 2 commits intoweecology:mainfrom
Open
Add regression test for read_file GeoDataFrame return type (#1186)#1339vickysharma-prog wants to merge 2 commits intoweecology:mainfrom
vickysharma-prog wants to merge 2 commits intoweecology:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1339 +/- ##
=======================================
Coverage 87.34% 87.34%
=======================================
Files 24 24
Lines 2978 2978
=======================================
Hits 2601 2601
Misses 377 377
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
henrykironde
requested changes
Mar 7, 2026
Contributor
henrykironde
left a comment
There was a problem hiding this comment.
I will leave this to Ben to have a look
|
|
||
| assert isinstance(result_wkt, gpd.GeoDataFrame) | ||
| assert isinstance(result_wkt.geometry, gpd.GeoSeries) | ||
| assert 'geometry' in result_wkt.columns |
Contributor
There was a problem hiding this comment.
you probably want to move this statement
assert 'geometry' in result_wkt.columns
above
assert isinstance(result_wkt.geometry, gpd.GeoSeries)
Contributor
Author
|
Thanks @henrykironde @bw4sz ! Fixed the assertion order in both test cases. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds a regression test for #1186 to ensure read_file() returns a proper GeoDataFrame when passed a pandas DataFrame with an existing geometry column.
Background
Issue #1186 reported that read_file() was returning a pandas DataFrame with shapely geometry column instead of a proper GeoDataFrame. This prevented use of GeoDataFrame methods like .intersects() required by preprocess.split_raster.
The bug was fixed by @bw4sz in commit 6f0aca1 (Refactor read_file - #1042). The refactor introduced DeepForest_DataFrame which properly inherits from GeoDataFrame. However, the specific regression test requested in #1186 was not added.
This PR adds that test to prevent future regressions.
Test Coverage
Test Case 1: DataFrame with WKT string geometry -> Verifies GeoDataFrame + GeoSeries
Test Case 2: DataFrame with shapely geometry objects -> Verifies GeoDataFrame + GeoSeries
Assertions:
Related Issue(s)
Closes #1186
AI-Assisted Development
AI tools used (if applicable):
AI tools used for initial research and understanding the codebase better. All code was written and verified manually.