Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
#1072 fix float rounding for box size
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Jan 17, 2024
1 parent cd2496f commit aeb35c8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ def _construct_comment(self) -> str:
"Hyperion: Xray centring - Diffraction grid scan of "
f"{self.full_params.experiment_params.x_steps} by "
f"{self.y_steps} images in "
f"{self.full_params.experiment_params.x_step_size*1e3} um by "
f"{self.y_step_size*1e3} um steps. "
f"{(self.full_params.experiment_params.x_step_size*1e3):.1f} um by "
f"{(self.y_step_size*1e3):.1f} um steps. "
f"Top left (px): [{int(self.upper_left[0])},{int(self.upper_left[1])}], "
f"bottom right (px): [{bottom_right[0]},{bottom_right[1]}]."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def test_ispyb_deposition_comment_correct(


@patch("ispyb.open", autospec=True)
def test_ispyb_deposition_rounds_to_int(
def test_ispyb_deposition_rounds_position_to_int(
mock_ispyb_conn: MagicMock,
dummy_ispyb: Store2DGridscanInIspyb,
):
Expand All @@ -497,6 +497,44 @@ def test_ispyb_deposition_rounds_to_int(
)


@pytest.mark.parametrize(
["raw", "rounded"],
[
(0.0012345, "1.2"),
(0.020000000, "20.0"),
(0.01999999, "20.0"),
(0.015257, "15.3"),
(0.0001234, "0.1"),
(0.0017345, "1.7"),
(0.0019945, "2.0"),
],
)
@patch(
"hyperion.external_interaction.ispyb.store_datacollection_in_ispyb.oav_utils.bottom_right_from_top_left",
autospec=True,
)
def test_ispyb_deposition_rounds_box_size_int(
bottom_right_from_top_left: MagicMock,
dummy_ispyb: Store2DGridscanInIspyb,
dummy_params: GridscanInternalParameters,
raw,
rounded,
):
bottom_right_from_top_left.return_value = dummy_ispyb.upper_left = [0, 0, 0]
dummy_ispyb.ispyb_params = MagicMock()
dummy_ispyb.full_params = dummy_params
dummy_ispyb.y_steps = dummy_ispyb.full_params.experiment_params.x_steps = 0

dummy_ispyb.y_step_size = (
dummy_ispyb.full_params.experiment_params.x_step_size
) = raw

assert dummy_ispyb._construct_comment() == (
"Hyperion: Xray centring - Diffraction grid scan of 0 by 0 images in "
f"{rounded} um by {rounded} um steps. Top left (px): [0,0], bottom right (px): [0,0]."
)


@patch("ispyb.open", autospec=True)
def test_ispyb_deposition_comment_for_3D_correct(
mock_ispyb_conn: MagicMock,
Expand Down

0 comments on commit aeb35c8

Please sign in to comment.