Skip to content

Conversation

srishtysajeev
Copy link
Contributor

@srishtysajeev srishtysajeev commented Sep 26, 2025

Fixes #1567

Instructions to reviewer on how to test:

  1. Check for any mistakes within the code / comments
  2. Check that the tests are correct
  3. Check that the tests run

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
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@srishtysajeev srishtysajeev requested a review from a team as a code owner September 26, 2025 13:24
@srishtysajeev srishtysajeev changed the title 1567 move scintillator to beam Add ability to move scintillator in to beam for i04 Sep 26, 2025
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.80%. Comparing base (19f468c) to head (9aea822).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1583      +/-   ##
==========================================
+ Coverage   98.77%   98.80%   +0.02%     
==========================================
  Files         246      250       +4     
  Lines        8845     9003     +158     
==========================================
+ Hits         8737     8895     +158     
  Misses        108      108              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Thanks, some comments in code but mostly quite minor

Comment on lines 71 to 79
elif all(
isclose(axis_pos, axis_in_beam, abs_tol=axis_tolerance)
for axis_pos, axis_in_beam, axis_tolerance in zip(
current_pos,
self._scintillator_in_yz_mm,
self._yz_tolerance_mm,
strict=False,
)
):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: Can you pull this out into a function? Something like:

def check_at_position(current_position: tuple[float, float], position_to_check: tuple[float, float]):
    return all(
            isclose(axis_pos, axis_in_beam, abs_tol=axis_tolerance)
            for axis_pos, axis_in_beam, axis_tolerance in zip(
                current_position,
                position_to_check,
                self._yz_tolerance_mm,
                strict=False,
            )
        )

Then use it here and above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should the function be a 'hidden function' I mean with the '_' at the start?

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed in person. Yes it should be private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done that now - made them all private

Comment on lines 98 to 104
if (
self._aperture_scatterguard().selected_aperture.get_value()
!= ApertureValue.PARKED
):
raise ValueError(
"Cannot move scintillator in if aperture/scatterguard is not parked"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: Can you pull this into a function of something like check_aperture_parked?

Comment on lines 88 to 92
await scintillator.selected_pos.set(InOut.IN)

assert await scintillator.y_mm.user_setpoint.get_value() == 100.855
assert await scintillator.z_mm.user_setpoint.get_value() == 101.5115

Copy link
Contributor

Choose a reason for hiding this comment

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

Should: It's better to put this in it's own test, because then it's more obvious what exactly is failing. This test name also references it being set to out but here you're setting it to in

Copy link
Contributor

@oliwenmandiamond oliwenmandiamond Sep 26, 2025

Choose a reason for hiding this comment

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

We should also probably be using the assert_value testing function from ophyd_async e.g

from ophyd_async.testing import assert_value
...
await assert_value(scintillator.y_mm.user_setpoint, 100.855)

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.

Add ability to move scintillator into beam
3 participants