Get codespell passing and add it as a CI job.
This commit is contained in:
parent
e33fecaef0
commit
7e6017f648
25 changed files with 113 additions and 85 deletions
|
|
@ -1,5 +1,5 @@
|
|||
"""A package of test module providing mock Things for testing.
|
||||
|
||||
The mock things do not subclass the origninal things to minimise the inflation of
|
||||
The mock things do not subclass the original things to minimise the inflation of
|
||||
test coverage.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ def test_buffer_size_changing():
|
|||
misc_image3 = random_image()
|
||||
buffer_id1 = mem_buf.add_image(misc_image1, buffer_max=3)
|
||||
buffer_id2 = mem_buf.add_image(misc_image2, buffer_max=3)
|
||||
# Third capture doen't set buffer size, so it will be reset
|
||||
# Third capture doesn't set buffer size, so it will be reset
|
||||
buffer_id3 = mem_buf.add_image(misc_image3)
|
||||
# As buffer size was reset, images 1 and 2 are deleted
|
||||
with pytest.raises(NoImageInMemoryError):
|
||||
|
|
@ -201,7 +201,7 @@ def test_get_metadata_too():
|
|||
# Preallocate zipped data, to avoid long confusing lines
|
||||
zipped = zip(images, metadatas, buffer_ids)
|
||||
|
||||
# Check both image and metdata
|
||||
# Check both image and metadata
|
||||
for i, (image, metadata, buffer_id) in enumerate(zipped):
|
||||
returned_image, returned_metadata = mem_buf.get_image(buffer_id)
|
||||
assert image is returned_image
|
||||
|
|
|
|||
|
|
@ -37,24 +37,24 @@ def test_enforce_xyz_tuple():
|
|||
|
||||
def test_base_class_not_implemented():
|
||||
"""Check NotImplementedError is raised when initialising ScanPlanner directly."""
|
||||
intial_position = (100, 50)
|
||||
initial_position = (100, 50)
|
||||
with pytest.raises(NotImplementedError):
|
||||
scan_planners.ScanPlanner(intial_position=intial_position)
|
||||
scan_planners.ScanPlanner(initial_position=initial_position)
|
||||
|
||||
|
||||
def test_v_basic_smart_spiral():
|
||||
"""Check that a SmartSpiral where the first image is not sample completes."""
|
||||
intial_position = (100, 50)
|
||||
initial_position = (100, 50)
|
||||
planner_settings = {"dx": 50, "dy": 50, "max_dist": 10000}
|
||||
planner = scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=planner_settings
|
||||
initial_position=initial_position, planner_settings=planner_settings
|
||||
)
|
||||
# Create a planner. It shouldn't be complete.
|
||||
assert not planner.scan_complete
|
||||
# When we start it should want to stay in the inital pos and have
|
||||
# When we start it should want to stay in the initial pos and have
|
||||
# no z_estimate
|
||||
xy_pos, z_pos = planner.get_next_location_and_z_estimate()
|
||||
assert xy_pos == intial_position
|
||||
assert xy_pos == initial_position
|
||||
assert z_pos is None
|
||||
|
||||
# Try to mark location as imaged with only xy_position
|
||||
|
|
@ -76,11 +76,11 @@ def test_v_basic_smart_spiral():
|
|||
|
||||
def test_bad_smart_spiral_settings():
|
||||
"""Check that KeyError is raised when SmartSpiral is given bad settings."""
|
||||
intial_position = (100, 50)
|
||||
initial_position = (100, 50)
|
||||
|
||||
# Class init should raise error if no planner_settings dictionary set
|
||||
with pytest.raises(ValueError):
|
||||
scan_planners.SmartSpiral(intial_position=intial_position)
|
||||
scan_planners.SmartSpiral(initial_position=initial_position)
|
||||
|
||||
planner_settings = {"dx": 50, "dy": 50, "max_dist": 10000}
|
||||
keys = ["dx", "dy", "max_dist"]
|
||||
|
|
@ -91,7 +91,7 @@ def test_bad_smart_spiral_settings():
|
|||
del bad_planner_settings[delkey]
|
||||
with pytest.raises(KeyError):
|
||||
scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=bad_planner_settings
|
||||
initial_position=initial_position, planner_settings=bad_planner_settings
|
||||
)
|
||||
|
||||
# Class init should raise error if planner_settings if any value can't be cast
|
||||
|
|
@ -102,7 +102,7 @@ def test_bad_smart_spiral_settings():
|
|||
bad_planner_settings[badkey] = "I can't be converted to an int"
|
||||
with pytest.raises(ValueError):
|
||||
scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=bad_planner_settings
|
||||
initial_position=initial_position, planner_settings=bad_planner_settings
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -113,18 +113,18 @@ def test_smart_spiral_first_few_pos():
|
|||
that data is added correctly for the first few positions in a scan. It is
|
||||
intended to catch basic issues if the algorithm is updated.
|
||||
"""
|
||||
intial_position = (100, 50)
|
||||
initial_position = (100, 50)
|
||||
planner_settings = {"dx": 50, "dy": 50, "max_dist": 10000}
|
||||
# Create a planner
|
||||
planner = scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=planner_settings
|
||||
initial_position=initial_position, planner_settings=planner_settings
|
||||
)
|
||||
# it shouldn't start complete
|
||||
assert not planner.scan_complete
|
||||
# When we start it should want to stay in the inital pos and have
|
||||
# When we start it should want to stay in the initial pos and have
|
||||
# no z_estimate
|
||||
xy_pos1, z_pos1 = planner.get_next_location_and_z_estimate()
|
||||
assert xy_pos1 == intial_position
|
||||
assert xy_pos1 == initial_position
|
||||
assert z_pos1 is None
|
||||
# Set a focus value
|
||||
z_focus = 10
|
||||
|
|
@ -201,11 +201,11 @@ def test_smart_spiral_first_few_pos():
|
|||
|
||||
def test_smart_spiral_stops_on_max_dist():
|
||||
"""Test that if max distance is reached smart spiral really does stop."""
|
||||
intial_position = (0, 0)
|
||||
initial_position = (0, 0)
|
||||
planner_settings = {"dx": 100, "dy": 100, "max_dist": 1000}
|
||||
# Create a planner
|
||||
planner = scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=planner_settings
|
||||
initial_position=initial_position, planner_settings=planner_settings
|
||||
)
|
||||
while not planner.scan_complete:
|
||||
xy_pos, _ = planner.get_next_location_and_z_estimate()
|
||||
|
|
@ -219,11 +219,11 @@ def test_smart_spiral_stops_on_max_dist():
|
|||
|
||||
def test_mark_wrong_location():
|
||||
"""Check that an error is raised if a scan marks the wrong location as visited."""
|
||||
intial_position = (100, 50)
|
||||
initial_position = (100, 50)
|
||||
planner_settings = {"dx": 50, "dy": 50, "max_dist": 10000}
|
||||
# Create a planner
|
||||
planner = scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=planner_settings
|
||||
initial_position=initial_position, planner_settings=planner_settings
|
||||
)
|
||||
|
||||
xy_pos, _ = planner.get_next_location_and_z_estimate()
|
||||
|
|
@ -233,18 +233,18 @@ def test_mark_wrong_location():
|
|||
planner.mark_location_visited(wrong_xyz_pos, imaged=True, focused=True)
|
||||
|
||||
|
||||
def test_closest_focus_wth_large_numbers():
|
||||
def test_closest_focus_with_large_numbers():
|
||||
"""Tests to check that everything works well with huge numbers of steps.
|
||||
|
||||
The number of steps gets very large on the micorscope. But most of the tests
|
||||
above use smaller numbers for clarity.
|
||||
"""
|
||||
intial_position = (0, 0)
|
||||
initial_position = (0, 0)
|
||||
# Set this up, but we won't use the settings
|
||||
planner_settings = {"dx": 10000, "dy": 10000, "max_dist": 100000}
|
||||
# Create a planner
|
||||
planner = scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=planner_settings
|
||||
initial_position=initial_position, planner_settings=planner_settings
|
||||
)
|
||||
# Directly overwrite the private focussed locations list for test
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def test_initial_properties(smart_scan_thing):
|
|||
def test_inaccessible_scan_methods(smart_scan_thing):
|
||||
"""Test that method with @_scan_running decorator is inaccessible.
|
||||
|
||||
The @_scan_running decorator makes these functions inacessible unless
|
||||
The @_scan_running decorator makes these functions inaccessible unless
|
||||
a scan is running.
|
||||
"""
|
||||
with pytest.raises(ScanNotRunningError):
|
||||
|
|
@ -151,7 +151,7 @@ def test_delete_all_scans(smart_scan_thing, caplog):
|
|||
assert len(caplog.records) == 0
|
||||
|
||||
|
||||
def _run_only_outer_scan(adjust_inital_state: Optional[Callable] = None):
|
||||
def _run_only_outer_scan(adjust_initial_state: Optional[Callable] = None):
|
||||
"""Create a subclass of SmartScanThing to mock _run_scan and run sample_scan.
|
||||
|
||||
This should do all the set up for a scan, move into the mocked
|
||||
|
|
@ -199,8 +199,8 @@ def _run_only_outer_scan(adjust_inital_state: Optional[Callable] = None):
|
|||
# mock smart scan thing
|
||||
mock_ss_thing = MockedSmartScanThing(SCAN_DIR)
|
||||
|
||||
if adjust_inital_state is not None:
|
||||
adjust_inital_state(mock_ss_thing)
|
||||
if adjust_initial_state is not None:
|
||||
adjust_initial_state(mock_ss_thing)
|
||||
|
||||
exec_info = None
|
||||
try:
|
||||
|
|
@ -232,7 +232,7 @@ def _run_only_outer_scan(adjust_inital_state: Optional[Callable] = None):
|
|||
assert mock_ss_thing._scan_images_taken is None
|
||||
|
||||
# Return the mock thing for further state testing, and the
|
||||
# exec_info of any uncaught exeptions that were raised
|
||||
# exec_info of any uncaught exceptions that were raised
|
||||
return mock_ss_thing, exec_info
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ def interp_closed_path(xy_points: list[tuple[int, int]], n_points: int) -> MatPa
|
|||
Modified from:
|
||||
https://stackoverflow.com/questions/33962717/interpolating-a-closed-curve-using-scipy
|
||||
"""
|
||||
# Use zip to seperate x and y points into tuples
|
||||
# Use zip to separate x and y points into tuples
|
||||
x, y = zip(*xy_points)
|
||||
|
||||
# Append first point and convert to array
|
||||
|
|
@ -119,10 +119,10 @@ def example_smart_spiral(
|
|||
xy_sample_points = load_sample_points(sample_name)
|
||||
sample = FakeSample(xy_sample_points)
|
||||
img_size = (1000, 1000)
|
||||
intial_position = (0, 0)
|
||||
initial_position = (0, 0)
|
||||
planner_settings = {"dx": 1200, "dy": 800, "max_dist": 100000}
|
||||
planner = scan_planners.SmartSpiral(
|
||||
intial_position=intial_position, planner_settings=planner_settings
|
||||
initial_position=initial_position, planner_settings=planner_settings
|
||||
)
|
||||
|
||||
while not planner.scan_complete:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue