-
Notifications
You must be signed in to change notification settings - Fork 20
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
Change default behaviour of crop to inplace=False #439
Conversation
…lse. Integrates versioning fixes.
… dict - function was returning KeyError rather than TypeError)
I should also note that I checked for other possible uses of |
Great @atedstone! |
I now realise that Vector.crop() also needs changing - will do this and add to this PR. |
On my side this PR is ready for review and merging. |
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.
Amazing!!
So it's having inplace: bool = ...
repeated in an @overload
above the main function definition that made MyPy happy in the end?
@@ -1899,7 +1899,7 @@ def crop( | |||
self._data = crop_img | |||
self.transform = tfm | |||
self.tags["AREA_OR_POINT"] = "Area" # TODO: Explain why this should have an area interpretation now | |||
return None | |||
return self |
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.
This should still return None
if it is inplace and crop_img
was already written to .data
, no? 🤔
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 agree, we should not return self, if the data is modified in place, otherwise this becomes confusing...
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.
hmm, ok it looks like this snuck through, which was not the intention. I did this when having problems with @overload
but that got resolved. Will sort soon, for the moment I'll open a bug
This PR creates breaking changes to the API
Resolves part of #432:
Raster.crop()
is nowinplace=False
by default. This aligns its functionality withRaster.reproject()
and with other projects more generally such as xarray.The PR also fixes a bug in
test_projtools:test_utm_to_epsg
. A KeyError was being returned byproj_tools.utm_to_epsg()
:This is now fixed by requiring a
str
type inutm_to_epsg()
, allowing all tests to pass locally on my machine.