-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add a function to join/enclose areas. #306
Conversation
Add a function to calculate an area enclosing one or more other areas.
👉 View analysis in DeepCode’s Dashboard | Configure the bot |
I disagree with deepcodes suggestion. Explicit is better than implicit. PEP 8 does NOT recommend against ``if len(x) == 0``, it recommends against ``if not len(x)``. According to "Explicit is better than implicit", ``if len(x) == 0`` should be preferable and clearer. However, I will adapt it anyway as deepcode is the boss here?
The AppVeyor build failure appears unrelated to this PR. |
This reminds me of |
Also what are your thoughts on this being a method on the AreaDefinition itself? We could even overload the |
Merge could be another word. I chose enclose because the resulting area includes not only the area covered by the input areas, but also the area in-between. I borrowed this word from the portion library. I'm open to add it as a classmethod/constructor on the |
Good points. Maybe |
|
If Python had range literals that would be an appropriate syntax for this. Wild idea: create a special object |
Alright, fine. I suppose the I wonder if we can or should come up with notation for these types of operations for a pyresample 2.0 kind of interface. |
How about |
@mraspaud The enclosure is neither a union nor an intersection. It's the geo-2d equivalent of what pyinterval calls the enclosure. The union Any actual union or intersection function would either need to be very restrictive on its inputs (such as |
Codecov Report
@@ Coverage Diff @@
## master #306 +/- ##
==========================================
+ Coverage 92.97% 92.99% +0.02%
==========================================
Files 48 48
Lines 9764 9798 +34
==========================================
+ Hits 9078 9112 +34
Misses 686 686
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
LGTM.
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.
Small request to use CRS. Otherwise for the name, I found this https://en.wikipedia.org/wiki/Minimum_bounding_box
So enclosing is definitely the right concept. However, should a function name use a verb? Or indicate an action? Something like "enclose_areas" or "enclosed_area" or "enclosing_area_box" (nah maybe not this one). I suppose "area_enclosure" works, I'm just worried I'm not going to find it later. Should something be added to the documentation? I'm not sure where given the current (terrible) organization of the sphinx docs.
pyresample/geometry.py
Outdated
|
||
return create_area_def( | ||
area_id=area_id, | ||
projection=first.proj_dict, |
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.
After #332, this should be changed to .crs
. Actually, it could be done now and should still work. Passing PROJ dicts in is fine, using them after is not. Ah you also use proj_dict below to get the units. This shouldn't be necessary as create_area_def
should determine the units from the CRS information.
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.
If I change first.proj_dict
to first.crs
the test fails with TypeError: Wrong type for projection: <class 'pyproj.crs.crs.CRS'>. Expected dict or string.
in _get_proj_data
, which verifies that the projection is either a dict or a string.
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 think in #332 that should work. Once some of my more recent PRs are merged maybe we can test this idea again.
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.
Should I wait for merger of #332 and then adapt the code here?
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.
Merged just now. If you have the time to merge master into this PR and test some things that'd be great. Thanks.
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.
Replaced proj_dict
by crs
.
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.
Changed name to enclose_areas
.
Change the name of the function area_enclosure to enclose_areas.
Remove duplicate "import pytest" in test_geometry.py.
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.
LGTM, nice feature!
Add a function to calculate an area enclosing one or more other areas.
git diff origin/master **/*py | flake8 --diff