diff --git a/pyproject.toml b/pyproject.toml index bc44d831..bb3a4cb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ 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 statments "RSE", # Raise parentheses # "SIM", # Simplifications detected "ARG", # unused arguments diff --git a/src/openflexure_microscope_server/things/auto_recentre_stage.py b/src/openflexure_microscope_server/things/auto_recentre_stage.py index 910a44cf..bbdd5635 100644 --- a/src/openflexure_microscope_server/things/auto_recentre_stage.py +++ b/src/openflexure_microscope_server/things/auto_recentre_stage.py @@ -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 + if turning_loc < np.min(sorted_lateral): + moves = -1 + elif turning_loc > np.max(sorted_lateral): + moves = 1 # Centre value is replaced by the maximum value recorded in that axis centre[direction] = focused_pos[direction][np.argmax(all_heights)][ diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index 1a14f074..dd4a388a 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -105,11 +105,12 @@ 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: - raise e + 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) logging.debug("changing stop to %s", (stop)) diff --git a/src/openflexure_microscope_server/things/background_detect.py b/src/openflexure_microscope_server/things/background_detect.py index 744ed402..897234c3 100644 --- a/src/openflexure_microscope_server/things/background_detect.py +++ b/src/openflexure_microscope_server/things/background_detect.py @@ -23,8 +23,7 @@ class BackgroundDetectThing(Thing): bd = self.thing_settings.get("background_distributions", None) if bd: return ChannelDistributions(**bd) - else: - return None + return None @background_distributions.setter def background_distributions(self, value: Optional[ChannelDistributions]) -> None: diff --git a/tests/utilities/scan_test_helpers.py b/tests/utilities/scan_test_helpers.py index 7ee583ed..62bb7f73 100644 --- a/tests/utilities/scan_test_helpers.py +++ b/tests/utilities/scan_test_helpers.py @@ -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):