Fixed ruff errors
This commit is contained in:
parent
e5b0c7f049
commit
1e7ad7bf29
2 changed files with 18 additions and 38 deletions
|
|
@ -372,9 +372,10 @@ def _motion_detection(
|
|||
|
||||
return stage.position
|
||||
|
||||
|
||||
def _collate_data(data: dict, time: float, csm: CSMDep) -> dict:
|
||||
"""Collate anmd calculate all useful data from ROM test.
|
||||
|
||||
|
||||
:param data: Dictionary created from ROM test.
|
||||
:param time: Total time of the range of motion test.
|
||||
:param csm: A direct_thing_client dependency for camera stage mapping.
|
||||
|
|
@ -575,9 +576,11 @@ class RangeofMotionThing(lt.Thing):
|
|||
end_time = time.time()
|
||||
total_time = (end_time - start_time) / 60
|
||||
|
||||
rom_results = _collate_data(data = rom_results, time=total_time, csm=csm)
|
||||
rom_results = _collate_data(data=rom_results, time=total_time, csm=csm)
|
||||
|
||||
logger.info(f"Range of motion is {rom_results['Step Range'][0]} X {rom_results['Step Range'][1]} steps")
|
||||
logger.info(
|
||||
f"Range of motion is {rom_results['Step Range'][0]} X {rom_results['Step Range'][1]} steps"
|
||||
)
|
||||
|
||||
self.last_calibration = DenumpifyingDict(rom_results).model_dump()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
"""File contains unit tests for stage_measure."""
|
||||
|
||||
import pytest
|
||||
from openflexure_microscope_server.things.stage_measure import (
|
||||
_generate_move_dicts,
|
||||
_predict_z,
|
||||
_parasitic_detect,
|
||||
ParasiticMotionError,
|
||||
_collate_data
|
||||
)
|
||||
|
||||
from openflexure_microscope_server.things import stage_measure as sm
|
||||
from .mock_things.mock_csm import MockCSMThing
|
||||
from .mock_things.mock_stage import MockStageThing
|
||||
|
||||
|
|
@ -21,7 +14,7 @@ def test_generate_move_dicts():
|
|||
mock_perc = 50
|
||||
mock_res = [820, 616]
|
||||
mock_dir = 1
|
||||
mock_dict = _generate_move_dicts(
|
||||
mock_dict = sm._generate_move_dicts(
|
||||
fov_perc=mock_perc, stream_resolution=mock_res, direction=mock_dir
|
||||
)
|
||||
expected_dict = {"x": 410, "y": 308}
|
||||
|
|
@ -40,7 +33,7 @@ def test_predict_z():
|
|||
]
|
||||
mock_axis = "x"
|
||||
mock_move = 2908
|
||||
mock_z_diff = _predict_z(
|
||||
mock_z_diff = sm._predict_z(
|
||||
positions=mock_positions,
|
||||
axis=mock_axis,
|
||||
relative_move=mock_move,
|
||||
|
|
@ -55,37 +48,21 @@ def test_parasitic_detect():
|
|||
"""Check that the parasitic error is raised correctly."""
|
||||
mock_delta = 100
|
||||
mock_max = 50
|
||||
with pytest.raises(ParasiticMotionError):
|
||||
_parasitic_detect(delta=mock_delta, max_allowed_delta=mock_max)
|
||||
with pytest.raises(sm.ParasiticMotionError):
|
||||
sm._parasitic_detect(delta=mock_delta, max_allowed_delta=mock_max)
|
||||
|
||||
|
||||
def test_collate_data():
|
||||
"""Check that the data is being collected and calculated correctly."""
|
||||
mock_data = {
|
||||
"positive x": {
|
||||
"final_position": {
|
||||
"x": 100
|
||||
}
|
||||
},
|
||||
"negative x": {
|
||||
"final_position": {
|
||||
"x": 50
|
||||
}
|
||||
},
|
||||
"positive y": {
|
||||
"final_position": {
|
||||
"y": 100
|
||||
}
|
||||
},
|
||||
"negative y": {
|
||||
"final_position": {
|
||||
"y": 50
|
||||
}
|
||||
"positive x": {"final_position": {"x": 100}},
|
||||
"negative x": {"final_position": {"x": 50}},
|
||||
"positive y": {"final_position": {"y": 100}},
|
||||
"negative y": {"final_position": {"y": 50}},
|
||||
}
|
||||
}
|
||||
|
||||
mock_step_range = [50, 50]
|
||||
|
||||
mock_time = 123
|
||||
mock_dict = _collate_data(data=mock_data, time=mock_time, csm=MockCSMThing)
|
||||
mock_dict = sm._collate_data(data=mock_data, time=mock_time, csm=MockCSMThing)
|
||||
|
||||
assert mock_dict["Step Range"] == mock_step_range
|
||||
assert mock_dict["Step Range"] == mock_step_range
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue