From dd82528d787172006b8e8aa04f0bbf981023638a Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 6 Nov 2019 22:13:39 +0000 Subject: [PATCH] Blackened --- openflexure_microscope/api/app.py | 4 +- openflexure_microscope/microscope.py | 8 +- .../plugins/default/scan/plugin.py | 88 ++++++++++--------- 3 files changed, 51 insertions(+), 49 deletions(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index c8593c8d..129e4383 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -90,7 +90,9 @@ api_microscope.attach(api_camera, api_stage) # Restore loaded capture array to camera object logging.debug("Restoring captures...") -api_microscope.camera.images = build_captures_from_exif(api_microscope.camera.paths["default"]) +api_microscope.camera.images = build_captures_from_exif( + api_microscope.camera.paths["default"] +) logging.debug("Microscope successfully attached!") diff --git a/openflexure_microscope/microscope.py b/openflexure_microscope/microscope.py index 11a03987..df6b0cf8 100644 --- a/openflexure_microscope/microscope.py +++ b/openflexure_microscope/microscope.py @@ -143,17 +143,13 @@ class Microscope: self.attach_plugins(self.plugin_maps) def has_real_stage(self): - if hasattr(self, "stage") and not isinstance( - self.stage, MockStage - ): + if hasattr(self, "stage") and not isinstance(self.stage, MockStage): return True else: return False def has_real_camera(self): - if hasattr(self, "camera") and not isinstance( - self.camera, MockStreamer - ): + if hasattr(self, "camera") and not isinstance(self.camera, MockStreamer): return True else: return False diff --git a/openflexure_microscope/plugins/default/scan/plugin.py b/openflexure_microscope/plugins/default/scan/plugin.py index 7918a895..0f9c09fa 100644 --- a/openflexure_microscope/plugins/default/scan/plugin.py +++ b/openflexure_microscope/plugins/default/scan/plugin.py @@ -7,7 +7,11 @@ import logging from openflexure_microscope.camera.base import generate_basename -from openflexure_microscope.devel import MicroscopePlugin, update_task_progress, update_task_data +from openflexure_microscope.devel import ( + MicroscopePlugin, + update_task_progress, + update_task_data, +) from .api import TileScanAPI @@ -64,15 +68,15 @@ class ScanPlugin(MicroscopePlugin): return progress def capture( - self, - basename, - scan_id, - temporary: bool = False, - use_video_port: bool = False, - resize: Tuple[int, int] = None, - bayer: bool = False, - metadata: dict = {}, - tags: list = [], + self, + basename, + scan_id, + temporary: bool = False, + use_video_port: bool = False, + resize: Tuple[int, int] = None, + bayer: bool = False, + metadata: dict = {}, + tags: list = [], ): # Construct a tile filename @@ -107,19 +111,19 @@ class ScanPlugin(MicroscopePlugin): output.put_tags(tags) def tile( - self, - basename: str = None, - temporary: bool = False, - step_size: int = [2000, 1500, 100], - grid: list = [3, 3, 5], - style="raster", - autofocus_dz: int = 50, - use_video_port: bool = False, - resize: Tuple[int, int] = None, - bayer: bool = False, - fast_autofocus=False, - metadata: dict = {}, - tags: list = [], + self, + basename: str = None, + temporary: bool = False, + step_size: int = [2000, 1500, 100], + grid: list = [3, 3, 5], + style="raster", + autofocus_dz: int = 50, + use_video_port: bool = False, + resize: Tuple[int, int] = None, + bayer: bool = False, + fast_autofocus=False, + metadata: dict = {}, + tags: list = [], ): # Keep task progress @@ -143,17 +147,17 @@ class ScanPlugin(MicroscopePlugin): # Check if autofocus is enabled if ( - autofocus_dz - and hasattr(self.microscope.plugin, "default_autofocus") - and self.microscope.has_real_stage() - and self.microscope.has_real_camera() + autofocus_dz + and hasattr(self.microscope.plugin, "default_autofocus") + and self.microscope.has_real_stage() + and self.microscope.has_real_camera() ): autofocus_enabled = True else: autofocus_enabled = False if fast_autofocus and not hasattr( - self.microscope.plugin.default_autofocus, "monitor_sharpness" + self.microscope.plugin.default_autofocus, "monitor_sharpness" ): logging.warning( "Can't use fast autofocus in the scan - the default plugin doesn't support monitor_sharpness; maybe it is too old?" @@ -241,7 +245,7 @@ class ScanPlugin(MicroscopePlugin): next_z = self.microscope.stage.position[2] if fast_autofocus: next_z += ( - autofocus_dz / 2 + autofocus_dz / 2 ) # Fast autofocus requires us to start at the top of the range if grid[2] > 1: next_z -= int( @@ -252,19 +256,19 @@ class ScanPlugin(MicroscopePlugin): self.microscope.stage.move_abs(initial_position) def stack( - self, - basename: str = None, - temporary: bool = False, - scan_id: str = None, - step_size: int = 100, - steps: int = 5, - center: bool = True, - return_to_start: bool = True, - use_video_port: bool = False, - resize: Tuple[int, int] = None, - bayer: bool = False, - metadata: dict = {}, - tags: list = [], + self, + basename: str = None, + temporary: bool = False, + scan_id: str = None, + step_size: int = 100, + steps: int = 5, + center: bool = True, + return_to_start: bool = True, + use_video_port: bool = False, + resize: Tuple[int, int] = None, + bayer: bool = False, + metadata: dict = {}, + tags: list = [], ): # Generate a basename if none given