Skip to content

Conversation

@d-chambers
Copy link
Contributor

@d-chambers d-chambers commented Sep 4, 2024

Description

This PR adds a add_distance_to patch 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):

  • referenced the GitHub issue this PR closes.
  • documented the new feature with docstrings or appropriate doc page.
  • included a test. See testing guidelines.
  • your name has been added to the contributors page (docs/contributors.md).
  • added the "ready_for_review" tag once the PR is ready to be reviewed.

@d-chambers d-chambers added ready_for_review PR is ready for review patch related to Patch class labels Sep 4, 2024
@codecov
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.84%. Comparing base (8fa6680) to head (620f844).
Report is 2 commits behind head on master.

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           
Flag Coverage Δ
unittests 99.84% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

>>>
>>> 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)
Copy link
Collaborator

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

Copy link
Collaborator

@ahmadtourei ahmadtourei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@d-chambers
Copy link
Contributor Author

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.

@d-chambers d-chambers merged commit acacac3 into master Sep 14, 2024
@d-chambers d-chambers deleted the add_distance branch September 14, 2024 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch related to Patch class ready_for_review PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants