-
Notifications
You must be signed in to change notification settings - Fork 28
add_distance_to #430
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_distance_to #430
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #430 +/- ##
=======================================
Coverage 99.84% 99.84%
=======================================
Files 112 112
Lines 9037 9065 +28
=======================================
+ Hits 9023 9051 +28
Misses 14 14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
dascore/proc/coords.py
Outdated
| >>> | ||
| >>> shot = pd.Series({"x": 10, "y": 10, "z": 0}) | ||
| >>> patch = dc.get_example_patch("random_patch_with_xyz") | ||
| >>> patch_with_distance = patch.add_distance_to(shot) |
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.
Suggest calling it patch_with_origin_dist
ahmadtourei
left a comment
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.
Looks great!
|
Thanks @ahmadtourei. I implemented your suggestion. I also got thinking and decided to store the origin location as coordinates (not associated with any dimension) rather than attributes. My thinking here is that we may want to support origin being a dataframe in the future, in which case the distance would be the shortest distance to any point in that dataframe. In such a case we would need to store arrays rather than single floats for each coordinate of the origin so this change helps future proof this method. |
Description
This PR adds a
add_distance_topatch method for calculating the distance to a point specified by a series. It can then be used to sort the channels of the patch. See #429.Checklist
I have (if applicable):