Skip to content
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

Open
wants to merge 10 commits into
base: development
Choose a base branch
from
Open

Typecheck spatial module #605

wants to merge 10 commits into from

Conversation

mfisher87
Copy link
Member

@mfisher87 mfisher87 commented Sep 10, 2024

Important

To be merged only after merging #604 and then rebasing

Copy link

github-actions bot commented Sep 10, 2024

Binder 👈 Launch a binder notebook on this branch for commit e314990

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit 7b563b1

Binder 👈 Launch a binder notebook on this branch for commit 1f1cfe5

Binder 👈 Launch a binder notebook on this branch for commit 749fc03

Binder 👈 Launch a binder notebook on this branch for commit a63ae13

@@ -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 ...))
Copy link
Member Author

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=}")
Copy link
Member Author

@mfisher87 mfisher87 Sep 10, 2024

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],
)
Copy link
Member Author

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]
Copy link
Member Author

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!

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 81.08108% with 7 lines in your changes missing coverage. Please review.

Project coverage is 65.34%. Comparing base (7b57037) to head (a63ae13).

Files with missing lines Patch % Lines
icepyx/core/spatial.py 79.41% 5 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

Base automatically changed from typecheck-temporal to development September 27, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant