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
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue