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

Pin tip centring now takes a median of values #242

Merged
merged 6 commits into from
Nov 27, 2023

Conversation

DominicOram
Copy link
Contributor

@DominicOram DominicOram commented Nov 24, 2023

Hot fixes part 2 of DiamondLightSource/hyperion#996

Instructions to reviewer on how to test:

  1. Confirm tests pass and are sensible

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards

def statistics_of_positions(positions: List[Tuple]):
x_coords, y_coords = np.array(positions).T

median = (int(np.median(x_coords)), int(np.median(y_coords)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we want these to be integers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. They're pixel values so we assumed they were integers later on for doing things like drawing grids and putting values into ispyb. Maybe I should do this conversion at the point we definitely need integers though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, there's so many places this could potentially break that I think conversion here makes sense, I will add a comment though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I added type hinting, which makes it clearer that these things are valid Pixel locations and so must be ints. Doesn't really answer your question 100% but hopefully makes it clearer?

Copy link

codecov bot commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7318343) 88.09% compared to head (104ce12) 88.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
+ Coverage   88.09%   88.29%   +0.19%     
==========================================
  Files          72       72              
  Lines        2587     2605      +18     
==========================================
+ Hits         2279     2300      +21     
+ Misses        308      305       -3     

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

@DominicOram DominicOram marked this pull request as ready for review November 27, 2023 10:56
@@ -19,16 +34,37 @@ class PinTipDetect(Device):

triggered_tip: Signal = Component(Signal, kind=Kind.hinted, value=INVALID_POSITION)
validity_timeout: Signal = Component(Signal, value=5)
settle_time_s: Signal = Component(Signal, value=0.5)

tip_positions: List[Tuple] = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like we don't need to define tip_positions here if it's also defined in trigger()

Copy link
Collaborator

@olliesilvester olliesilvester left a comment

Choose a reason for hiding this comment

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

This looks good, I think the tests are good too. I was going to comment on doing some tests regarding the logic of StableSubscriptionStatus, eg test_trigger_status_timeout_if_pin_doesnt_stay_valid, but I guess since this is a tested function in Ophyd then there's no need

@DominicOram DominicOram merged commit 4c1134b into main Nov 27, 2023
16 checks passed
@DominicOram DominicOram deleted the hyperion_996_hotfix_flaky_pin_tip_centring branch November 27, 2023 13:20
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.

2 participants