Merge branch 'more-checkers' into 'v3'
Enable more lint checkers See merge request openflexure/openflexure-microscope-server!290
This commit is contained in:
commit
c43b7cb8b4
11 changed files with 29 additions and 36 deletions
|
|
@ -102,22 +102,21 @@ select = [
|
|||
# "PL", # Pylint (a subset of, catches far less than pylint does)
|
||||
# "B", # Flake8 bugbear
|
||||
"A", # Flake8 builtins checker
|
||||
# "C", # Flake8 comprehensions
|
||||
"C", # Flake8 comprehensions
|
||||
# "FIX", #TODO/FIXME's in code. These should be added during develoment for ongoing tasks.
|
||||
# If they are not fixed before merge they should be converted to GitLab issues
|
||||
# "LOG", # Flake8 logging issues (pedantic logger formatting issues can be added with "G")
|
||||
# "T20", # Warns for print statments, production code should log
|
||||
# "PT", # pytest linting
|
||||
# "RET", # Consistent clear return statments
|
||||
"RET", # Consistent clear return statements
|
||||
"RSE", # Raise parentheses
|
||||
# "SIM", # Simplifications detected
|
||||
# "ARG", # unused arguments
|
||||
# "C90", # McCabe complexity!
|
||||
"ARG", # unused arguments
|
||||
"C90", # McCabe complexity!
|
||||
"NPY", # Numpy linting
|
||||
"N", # PEP8 naming
|
||||
# "DOC", # Enforce argument, return, and raise to be mentioned in docstrings there is
|
||||
# also "D" but this even warns about docstring punctuation. Perhaps a step too
|
||||
# far?
|
||||
# "D", # Docstring checks these may need to be added gradually
|
||||
"ERA001", # Commented out code!
|
||||
]
|
||||
|
||||
ignore = [
|
||||
|
|
|
|||
|
|
@ -24,16 +24,15 @@ select = [
|
|||
"LOG", # Flake8 logging issues (pedantic logger formatting issues can be added with "G")
|
||||
"T20", # Warns for print statments, production code should log
|
||||
"PT", # pytest linting
|
||||
"RET", # Consistent clear return statments
|
||||
"RET", # Consistent clear return statements
|
||||
"RSE", # Raise parentheses
|
||||
"SIM", # Simplifications detected
|
||||
"ARG", # unused arguments
|
||||
"C90", # McCabe complexity!
|
||||
"NPY", # Numpy linting
|
||||
"N", # PEP8 naming
|
||||
"DOC", # Enforce argument, return, and raise to be mentioned in docstrings there is
|
||||
# also "D" but this even warns about docstring punctuation. Perhaps a step too
|
||||
# far?
|
||||
"D", # Docstring checks these may need to be added gradually
|
||||
"ERA001", # Commented out code!
|
||||
]
|
||||
|
||||
# Line length is set to 88 for ruff. This is what the formatter aims for
|
||||
|
|
|
|||
|
|
@ -118,20 +118,12 @@ class RecentringThing(Thing):
|
|||
logging.info(
|
||||
f"Breaking because the highest point is at {np.argmax(sorted_all_heights)} in the list"
|
||||
)
|
||||
# plt.plot(sorted_lateral, sorted_all_heights,'.')
|
||||
# plt.plot(sorted_lateral, quad_fit_func(sorted_lateral))
|
||||
# plt.show()
|
||||
|
||||
break
|
||||
else:
|
||||
if turning_loc < np.min(sorted_lateral):
|
||||
moves = -1
|
||||
elif turning_loc > np.max(sorted_lateral):
|
||||
moves = 1
|
||||
else:
|
||||
# plt.plot(sorted_lateral, sorted_all_heights,'.')
|
||||
# plt.plot(sorted_lateral, quad_fit_func(sorted_lateral))
|
||||
# plt.show()
|
||||
pass
|
||||
|
||||
# Centre value is replaced by the maximum value recorded in that axis
|
||||
centre[direction] = focused_pos[direction][np.argmax(all_heights)][
|
||||
|
|
|
|||
|
|
@ -105,10 +105,11 @@ class JPEGSharpnessMonitor:
|
|||
stop: int = int(np.argmax(jpeg_times > stage_times[1]))
|
||||
except ValueError as e:
|
||||
if np.sum(jpeg_times > stage_times[0]) == 0:
|
||||
raise ValueError(
|
||||
"No images were captured during the move of the stage. Perhaps the camera is not streaming images?"
|
||||
) from e
|
||||
else:
|
||||
errmsg = (
|
||||
"No images were captured during the move of the stage. "
|
||||
"Perhaps the camera is not streaming images?"
|
||||
)
|
||||
raise ValueError(errmsg) from e
|
||||
raise e
|
||||
if stop < 1:
|
||||
stop = len(jpeg_times)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ class BackgroundDetectThing(Thing):
|
|||
bd = self.thing_settings.get("background_distributions", None)
|
||||
if bd:
|
||||
return ChannelDistributions(**bd)
|
||||
else:
|
||||
return None
|
||||
|
||||
@background_distributions.setter
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class OpenCVCamera(BaseCamera):
|
|||
It's likely to be highly inefficient - raw and/or uncompressed captures using
|
||||
binary image formats will be added in due course.
|
||||
"""
|
||||
logging.warning(f"OpenCV camera doen't respect {resolution} setting")
|
||||
ret, frame = self.cap.read()
|
||||
if not ret:
|
||||
raise RuntimeError(
|
||||
|
|
@ -100,6 +101,7 @@ class OpenCVCamera(BaseCamera):
|
|||
|
||||
This function will produce a JPEG image.
|
||||
"""
|
||||
logging.warning(f"OpenCV camera doen't respect {resolution} setting")
|
||||
frame = self.capture_array()
|
||||
jpeg = cv2.imencode(".jpg", frame)[1].tobytes()
|
||||
exif_dict = {
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ class SimulatedCamera(BaseCamera):
|
|||
It's likely to be highly inefficient - raw and/or uncompressed captures using
|
||||
binary image formats will be added in due course.
|
||||
"""
|
||||
logging.warning(f"Simulation camera doen't respect {resolution} setting")
|
||||
return self.generate_frame()
|
||||
|
||||
@thing_action
|
||||
|
|
@ -201,6 +202,7 @@ class SimulatedCamera(BaseCamera):
|
|||
|
||||
This function will produce a JPEG image.
|
||||
"""
|
||||
logging.warning(f"Simulation camera doen't respect {resolution} setting")
|
||||
frame = self.capture_array()
|
||||
jpeg = cv2.imencode(".jpg", frame)[1].tobytes()
|
||||
exif_dict = {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ def make_hardware_interface(
|
|||
axes = stage.axis_names
|
||||
|
||||
def pos2dict(pos: Sequence[float]) -> Mapping[str, float]:
|
||||
return {k: p for k, p in zip(axes, pos)}
|
||||
return dict(zip(axes, pos))
|
||||
|
||||
def dict2pos(posd: Mapping[str, float]) -> Sequence[float]:
|
||||
return tuple(posd[k] for k in axes if k in posd)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class BaseStage(Thing):
|
|||
|
||||
position = PropertyDescriptor(
|
||||
Mapping[str, int],
|
||||
{k: 0 for k in _axis_names},
|
||||
dict.fromkeys(_axis_names, 0),
|
||||
description="Current position of the stage",
|
||||
readonly=True,
|
||||
observable=True,
|
||||
|
|
|
|||
|
|
@ -91,5 +91,5 @@ class DummyStage(BaseStage):
|
|||
It is intended for use after manually or automatically recentring the
|
||||
stage.
|
||||
"""
|
||||
self.position = {k: 0 for k in self.axis_names}
|
||||
self.position = dict.fromkeys(self.axis_names, 0)
|
||||
self.instantaneous_position = self.position
|
||||
|
|
|
|||
|
|
@ -189,8 +189,7 @@ def get_expected_result_for_example_smart_spiral(
|
|||
"""
|
||||
pkl_fname = os.path.join(THIS_DIR, f"example_smart_spiral_{sample_name}.pkl")
|
||||
with open(pkl_fname, "rb") as pkl_file_obj:
|
||||
planner = pickle.load(pkl_file_obj)
|
||||
return planner
|
||||
return pickle.load(pkl_file_obj)
|
||||
|
||||
|
||||
def load_sample_points(sample_name: str):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue