From 11a1fd7f8572b81b6a765a0658f467df22ae0f62 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Thu, 10 Jul 2025 10:43:05 +0100 Subject: [PATCH] Move ThingSetting and ThingProperty docstrings under the definition. --- .../things/autofocus.py | 41 ++++++++++--------- .../things/background_detect.py | 4 +- .../things/camera/picamera.py | 7 ++-- .../things/camera_stage_mapping.py | 6 +-- .../things/settings_manager.py | 4 +- .../things/smart_scan.py | 23 ++++------- .../things/stage/__init__.py | 4 +- 7 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index 2b894aa3..d7a56700 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -393,33 +393,34 @@ class AutofocusThing(lt.Thing): stack_images_to_save = lt.ThingSetting( initial_value=1, model=int, - description="""The number of images to save in a stack. - - Defaults to 1 unless you need to see either side of focus""", ) + """The number of images to save in a stack. + + Defaults to 1 unless you need to see either side of focus + """ stack_min_images_to_test = lt.ThingSetting( initial_value=9, model=int, - description="""The minimum number of images to capture in a stack. - - This many images are captures and tested for focus, if the focus - is not central enough more images may be captured. After new images - are captured the number sets the number of images used for checking - if focus is central. - - Defaults to 9 which balances reliability and speed - """, ) + """The minimum number of images to capture in a stack. - stack_dz = lt.ThingSetting( - initial_value=50, - model=int, - description="""Space in steps between images in a z-stack - Suggested is 50 for 60-100x - 100 for 40x - 200 for 20x""", - ) + This many images are captures and tested for focus, if the focus is not central + enough more images may be captured. After new images are captured the number sets + the number of images used for checking if focus is central. + + Defaults to 9 which balances reliability and speed/ + """ + + stack_dz = lt.ThingSetting(initial_value=50, model=int) + """Distance in steps between images in a z-stack. + + Suggested values: + + * 50 for 60-100x + * 100 for 40x + * 200 for 20x + """ @lt.thing_action def run_smart_stack( diff --git a/src/openflexure_microscope_server/things/background_detect.py b/src/openflexure_microscope_server/things/background_detect.py index bdc44e84..941aef30 100644 --- a/src/openflexure_microscope_server/things/background_detect.py +++ b/src/openflexure_microscope_server/things/background_detect.py @@ -53,14 +53,14 @@ class BackgroundDetectThing(lt.Thing): tolerance = lt.ThingSetting( initial_value=7.0, model=float, - description="How many standard deviations to allow for the background", ) + """How many standard deviations to allow for the background.""" fraction = lt.ThingSetting( initial_value=25.0, model=float, - description="How much of the image needs to be not background to label as sample", ) + """How much of the image needs to be not background to label as sample""" def background_mask(self, image: np.ndarray) -> np.ndarray: """Calculate a binary image, showing whether each pixel is background. diff --git a/src/openflexure_microscope_server/things/camera/picamera.py b/src/openflexure_microscope_server/things/camera/picamera.py index d40c8cf4..a5a801da 100644 --- a/src/openflexure_microscope_server/things/camera/picamera.py +++ b/src/openflexure_microscope_server/things/camera/picamera.py @@ -128,22 +128,22 @@ class StreamingPiCamera2(BaseCamera): stream_resolution = lt.ThingProperty( tuple[int, int], initial_value=(820, 616), - description="Resolution to use for the MJPEG stream", ) + """Resolution to use for the MJPEG stream.""" mjpeg_bitrate = lt.ThingProperty( Optional[int], initial_value=100000000, - description="Bitrate for MJPEG stream (None for default)", ) + """Bitrate for MJPEG stream (None for default).""" stream_active = lt.ThingProperty( bool, initial_value=False, - description="Whether the MJPEG stream is active", observable=True, readonly=True, ) + """Whether the MJPEG stream is active.""" def save_settings(self): """Override save_settings to ensure that camera properties don't recurse. @@ -282,6 +282,7 @@ class StreamingPiCamera2(BaseCamera): return cam.sensor_resolution tuning = lt.ThingSetting(Optional[dict], None, readonly=True) + """The Raspberry PiCamera Tuning File JSON.""" def _initialise_picamera(self): """Acquire the picamera device and store it as ``self._picamera``. diff --git a/src/openflexure_microscope_server/things/camera_stage_mapping.py b/src/openflexure_microscope_server/things/camera_stage_mapping.py index 7126fd98..7c028a53 100644 --- a/src/openflexure_microscope_server/things/camera_stage_mapping.py +++ b/src/openflexure_microscope_server/things/camera_stage_mapping.py @@ -283,11 +283,9 @@ class CameraStageMapper(lt.Thing): return np.array(displacement_matrix).tolist() last_calibration = lt.ThingSetting( - initial_value=None, - model=Optional[dict], - readonly=True, - description="The most recent CSM calibration", + initial_value=None, model=Optional[dict], readonly=True ) + """The most recent CSM calibration.""" @lt.thing_property def image_resolution(self) -> Optional[Tuple[float, float]]: diff --git a/src/openflexure_microscope_server/things/settings_manager.py b/src/openflexure_microscope_server/things/settings_manager.py index 63373988..3ad6d222 100644 --- a/src/openflexure_microscope_server/things/settings_manager.py +++ b/src/openflexure_microscope_server/things/settings_manager.py @@ -46,14 +46,14 @@ class SettingsManager(lt.Thing): external_metadata = lt.ThingSetting( initial_value={}, model=Mapping, - description="External metadata stored in the server's settings", ) + """External metadata stored in the server's settings.""" external_metadata_in_state = lt.ThingSetting( initial_value=[], model=Sequence[str], - description='A list of strings that are included in the "state" metadata', ) + """A list of strings that are included in the "state" metadata.""" @lt.thing_action def update_external_metadata( diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index d85e6a83..75bc943d 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -587,51 +587,46 @@ class SmartScanThing(lt.Thing): save_resolution = lt.ThingSetting( initial_value=(1640, 1232), model=tuple[int, int], - description=("A tuple of the image resolution to capture."), ) + """A tuple of the image resolution to capture.""" max_range = lt.ThingSetting( initial_value=45000, model=int, - description=( - "The maximum distance from the centre of the scan before we break in steps" - ), ) + """The maximum distance in steps from the centre of the scan.""" stitch_tiff = lt.ThingSetting( initial_value=False, model=bool, - description="Whether or not to also produce a pyramidal tiff", ) + """Whether or not to also produce a pyramidal tiff at the end of a scan.""" skip_background = lt.ThingSetting( initial_value=True, model=bool, - description="""Whether to detect and skip empty fields of view - - This uses the settings from the ``BackgroundDetectThing``.""", ) + """Whether to detect and skip empty fields of view. + + This uses the settings from the ``BackgroundDetectThing``.""" autofocus_dz = lt.ThingSetting( initial_value=1000, model=int, - description="The z distance to perform an autofocus in steps", ) + """The z distance to perform an autofocus in steps.""" overlap = lt.ThingSetting( initial_value=0.45, model=float, - description="The fraction (0-1) that adjacent images should overlap in x or y", ) + """The fraction (0-1) that adjacent images should overlap in x or y.""" stitch_automatically = lt.ThingSetting( initial_value=True, model=bool, - description=( - "Whether to run a final stitch at the end of the scan (assuming scan " - "success)" - ), ) + """Whether to run a final stitch at the end of a successful scan.""" @lt.thing_property def scans(self) -> list[scan_directories.ScanInfo]: diff --git a/src/openflexure_microscope_server/things/stage/__init__.py b/src/openflexure_microscope_server/things/stage/__init__.py index 809b50e1..ab753dce 100644 --- a/src/openflexure_microscope_server/things/stage/__init__.py +++ b/src/openflexure_microscope_server/things/stage/__init__.py @@ -23,18 +23,18 @@ class BaseStage(lt.Thing): position = lt.ThingProperty( Mapping[str, int], dict.fromkeys(_axis_names, 0), - description="Current position of the stage", readonly=True, observable=True, ) + """Current position of the stage.""" moving = lt.ThingProperty( bool, False, - description="Whether the stage is in motion", readonly=True, observable=True, ) + """Whether the stage is in motion.""" @property def thing_state(self):