-
Notifications
You must be signed in to change notification settings - Fork 107
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
Typecheck spatial module #605
base: development
Are you sure you want to change the base?
Conversation
👈 Launch a binder notebook on this branch for commit e314990 I will automatically update this comment whenever this PR is modified 👈 Launch a binder notebook on this branch for commit 7b563b1 👈 Launch a binder notebook on this branch for commit 1f1cfe5 👈 Launch a binder notebook on this branch for commit 749fc03 👈 Launch a binder notebook on this branch for commit a63ae13 |
e314990
to
7b563b1
Compare
icepyx/core/spatial.py
Outdated
@@ -47,17 +60,25 @@ def geodataframe(extent_type, spatial_extent, file=False, xdateline=None): | |||
>>> reg_a = ipx.Query('ATL06',[-55, 68, -48, 71],['2019-02-20','2019-02-28']) | |||
>>> gdf = geodataframe(reg_a.spatial.extent_type, reg_a.spatial.extent) | |||
>>> gdf.geometry | |||
0 POLYGON ((-48 68, -48 71, -55 71, -55 68, -48 ... | |||
0 POLYGON ((-48 68, -48 71, -55 71, -55 68, -48 ...)) |
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.
My editor was negatively impacted by the unclosed parentheses :X
raise TypeError("When 'file' is True, 'extent_type' must be 'polygon'") | ||
|
||
if isinstance(spatial_extent, str): | ||
raise TypeError(f"Expected list of floats, received {spatial_extent=}") |
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.
Moved the handling for the file case all to one place. Below here, the typechecker knows we're dealing with a list
cartesian_spatial_extent[1], | ||
cartesian_spatial_extent[2], | ||
cartesian_spatial_extent[3], | ||
) |
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.
The typechecker needs to know there are only 4 things being passed, since the 5th argument to box
must be a bool
. The typechecker doesn't understand *cartesian_spatial_extent[0:4]
to mean the same thing unfortunately.
gdf = gpd.GeoDataFrame(geometry=[bbox], crs="epsg:4326") | ||
# HACK: Disabled Pyright due to issue | ||
# https://github.com/geopandas/geopandas/issues/3115 | ||
return gpd.GeoDataFrame(geometry=[bbox], crs="epsg:4326") # pyright: ignore[reportCallIssue] |
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.
Avoiding use of state where we don't need it!
7b563b1
to
1f1cfe5
Compare
1f1cfe5
to
749fc03
Compare
e805f01
to
7b57037
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## typecheck-temporal #605 +/- ##
======================================================
- Coverage 65.48% 65.34% -0.15%
======================================================
Files 38 38
Lines 3132 3142 +10
Branches 601 554 -47
======================================================
+ Hits 2051 2053 +2
- Misses 990 999 +9
+ Partials 91 90 -1 ☔ View full report in Codecov by Sentry. |
Important
To be merged only after merging #604 and then rebasing