Add regression test for read_file GeoDataFrame return type (#1186)#1339
Add regression test for read_file GeoDataFrame return type (#1186)#1339vickysharma-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
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 |
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)
|
Thanks @henrykironde @bw4sz ! Fixed the assertion order in both test cases. |
|
@bw4sz Hi! Just a gentle follow-up I've addressed Henry's feedback on the assertion order. All CI checks are passing. |
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.