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