Add flake8 bugbear checks
This commit is contained in:
parent
7ea92ad55f
commit
6142a267db
11 changed files with 40 additions and 30 deletions
|
|
@ -147,13 +147,13 @@ def test_buffer_size_respected():
|
|||
|
||||
images = []
|
||||
buffer_ids = []
|
||||
for i in range(10):
|
||||
for _i in range(10):
|
||||
image = random_image()
|
||||
buffer_id = mem_buf.add_image(image, buffer_max=5)
|
||||
images.append(image)
|
||||
buffer_ids.append(buffer_id)
|
||||
|
||||
for i, (image, buffer_id) in enumerate(zip(images, buffer_ids)):
|
||||
for i, (image, buffer_id) in enumerate(zip(images, buffer_ids, strict=True)):
|
||||
if i < 5:
|
||||
with pytest.raises(NoImageInMemoryError):
|
||||
mem_buf.get_image(buffer_id)
|
||||
|
|
@ -168,7 +168,7 @@ def test_clear_buffer():
|
|||
|
||||
images = []
|
||||
buffer_ids = []
|
||||
for i in range(10):
|
||||
for _i in range(10):
|
||||
image = random_image()
|
||||
buffer_id = mem_buf.add_image(image, buffer_max=10)
|
||||
images.append(image)
|
||||
|
|
@ -178,7 +178,7 @@ def test_clear_buffer():
|
|||
mem_buf.clear()
|
||||
|
||||
# They are now gone
|
||||
for i, (image, buffer_id) in enumerate(zip(images, buffer_ids)):
|
||||
for _i, (_image, buffer_id) in enumerate(zip(images, buffer_ids, strict=True)):
|
||||
with pytest.raises(NoImageInMemoryError):
|
||||
mem_buf.get_image(buffer_id)
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ def test_get_metadata_too():
|
|||
images = []
|
||||
metadatas = []
|
||||
buffer_ids = []
|
||||
for i in range(10):
|
||||
for _i in range(10):
|
||||
image = random_image()
|
||||
metadata = random_metadata()
|
||||
buffer_id = mem_buf.add_image(image, metadata, buffer_max=10)
|
||||
|
|
@ -199,10 +199,10 @@ def test_get_metadata_too():
|
|||
buffer_ids.append(buffer_id)
|
||||
|
||||
# Preallocate zipped data, to avoid long confusing lines
|
||||
zipped = zip(images, metadatas, buffer_ids)
|
||||
zipped = zip(images, metadatas, buffer_ids, strict=True)
|
||||
|
||||
# Check both image and metadata
|
||||
for i, (image, metadata, buffer_id) in enumerate(zipped):
|
||||
for _i, (image, metadata, buffer_id) in enumerate(zipped):
|
||||
returned_image, returned_metadata = mem_buf.get_image(buffer_id)
|
||||
assert image is returned_image
|
||||
assert metadata is returned_metadata
|
||||
|
|
|
|||
|
|
@ -97,11 +97,11 @@ def test_stage(client):
|
|||
move = {"x": 1, "y": 2, "z": 3}
|
||||
stage.move_relative(**move)
|
||||
pos = stage.position
|
||||
for s, m, p in zip(start.values(), move.values(), pos.values()):
|
||||
for s, m, p in zip(start.values(), move.values(), pos.values(), strict=True):
|
||||
assert s + m == p
|
||||
stage.move_relative(**{k: -v for k, v in move.items()})
|
||||
pos = stage.position
|
||||
for s, p in zip(start.values(), pos.values()):
|
||||
for s, p in zip(start.values(), pos.values(), strict=True):
|
||||
assert s == p
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ def test_scan_info():
|
|||
scan_dir_manager = ScanDirectoryManager(BASE_SCAN_DIR)
|
||||
scan_dir = scan_dir_manager.new_scan_dir("fake_scan")
|
||||
|
||||
for i in range(17):
|
||||
for _i in range(17):
|
||||
_add_fake_image(scan_dir)
|
||||
info = scan_dir.scan_info()
|
||||
now = time.time()
|
||||
|
|
@ -273,7 +273,7 @@ def test_get_final_stitch():
|
|||
scan_dir = scan_dir_manager.new_scan_dir("fake_scan")
|
||||
|
||||
# Create some scan images files
|
||||
for i in range(17):
|
||||
for _i in range(17):
|
||||
_add_fake_image(scan_dir)
|
||||
|
||||
# No scans, so None should be returned, from both manager and scan dir
|
||||
|
|
@ -365,7 +365,7 @@ def test_zipping_scan_data():
|
|||
scan_dir = scan_dir_manager.new_scan_dir("fake_scan")
|
||||
|
||||
# Create 21 fake scan images, a fake stitch, and a fake zip
|
||||
for i in range(21):
|
||||
for _i in range(21):
|
||||
_add_fake_image(scan_dir)
|
||||
_add_fake_file(scan_dir, "fake_scan_0001_stitched.jpg", in_im_dir=True)
|
||||
_add_fake_file(scan_dir, "zipfile.zip")
|
||||
|
|
@ -502,7 +502,7 @@ def test_extracting_files():
|
|||
assert scan_dir._extract_dzi_files(scan_files) == []
|
||||
|
||||
# Add a number of images
|
||||
for i in range(2321):
|
||||
for _i in range(2321):
|
||||
_add_fake_image(scan_dir)
|
||||
|
||||
scan_files = scan_dir.get_scan_files()
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ def _test_move_relative(dummy_stage, axis_inverted, path):
|
|||
dummy_stage.move_relative(
|
||||
cancel=cancel, x=movement[0], y=movement[1], z=movement[2]
|
||||
)
|
||||
position = [pos + move for pos, move in zip(position, movement)]
|
||||
position = [pos + move for pos, move in zip(position, movement, strict=True)]
|
||||
stage_pos = dummy_stage.get_xyz_position()
|
||||
hw_pos = dummy_stage._hardware_position
|
||||
assert position[0] == stage_pos[0] == hw_pos["x"] * x_dir
|
||||
|
|
@ -244,7 +244,7 @@ def test_move_relative(stage_client, dummy_stage, path):
|
|||
axis_names = stage_client.axis_names
|
||||
# Create every combination of True/False for x,y,z.
|
||||
inversion_combinations = [
|
||||
dict(zip(axis_names, inverted))
|
||||
dict(zip(axis_names, inverted, strict=True))
|
||||
for inverted in itertools.product([True, False], repeat=len(axis_names))
|
||||
]
|
||||
print(path)
|
||||
|
|
@ -305,7 +305,7 @@ def test_move_absolute(stage_client, dummy_stage, path):
|
|||
axis_names = stage_client.axis_names
|
||||
# Create every combination of True/False for x,y,z.
|
||||
inversion_combinations = [
|
||||
dict(zip(axis_names, inverted))
|
||||
dict(zip(axis_names, inverted, strict=True))
|
||||
for inverted in itertools.product([True, False], repeat=len(axis_names))
|
||||
]
|
||||
for axis_inverted in inversion_combinations:
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ def visualise_scan(sample: FakeSample, planner: scan_planners.ScanPlanner) -> Fi
|
|||
"""For a given sample and scanner object return a matplotlib figure of the scan."""
|
||||
fig, ax = plt.subplots(figsize=(8, 8))
|
||||
ax.add_artist(sample.patch)
|
||||
xh, yh = zip(*planner._path_history)
|
||||
xi, yi, _ = zip(*planner._imaged_locations)
|
||||
xh, yh = zip(*planner._path_history, strict=True)
|
||||
xi, yi, _ = zip(*planner._imaged_locations, strict=True)
|
||||
|
||||
# convert history to numpy array so can calculate quiver arrows
|
||||
xh = np.array(xh)
|
||||
|
|
@ -91,7 +91,7 @@ def interp_closed_path(xy_points: list[tuple[int, int]], n_points: int) -> MatPa
|
|||
https://stackoverflow.com/questions/33962717/interpolating-a-closed-curve-using-scipy
|
||||
"""
|
||||
# Use zip to separate x and y points into tuples
|
||||
x, y = zip(*xy_points)
|
||||
x, y = zip(*xy_points, strict=True)
|
||||
|
||||
# Append first point and convert to array
|
||||
x = np.array(x + (x[0],))
|
||||
|
|
@ -105,7 +105,7 @@ def interp_closed_path(xy_points: list[tuple[int, int]], n_points: int) -> MatPa
|
|||
xi, yi = interpolate.splev(np.linspace(0, 1, n_points), spline_data)
|
||||
|
||||
# Convert to a matplotlib closed path
|
||||
path_points = [[xp, yp] for xp, yp in (zip(xi, yi))]
|
||||
path_points = [[xp, yp] for xp, yp in (zip(xi, yi, strict=True))]
|
||||
return MatPath(path_points, closed=True)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue