From e49eba0366533c620a4a9399413f4c25b38fc230 Mon Sep 17 00:00:00 2001 From: Eoghan O'Connell Date: Wed, 27 Nov 2024 16:36:53 +0100 Subject: [PATCH] ref: docstrings - remove duplicate info but keep array shape info --- dclab/features/bright.py | 13 ++++++------- dclab/features/bright_bc.py | 13 ++++++------- dclab/features/bright_perc.py | 7 +++---- dclab/features/fl_crosstalk.py | 14 +++++++------- dclab/features/inert_ratio.py | 8 ++++---- dclab/features/volume.py | 22 ++++++++++++---------- 6 files changed, 38 insertions(+), 39 deletions(-) diff --git a/dclab/features/bright.py b/dclab/features/bright.py index 9845ac2c..221af38d 100644 --- a/dclab/features/bright.py +++ b/dclab/features/bright.py @@ -10,12 +10,11 @@ def get_bright(mask: npt.NDArray[bool] | list[npt.NDArray[bool]], image: npt.NDArray | list[npt.NDArray], - ret_data: str = "avg,sd") -> ( - float | - npt.NDArray | - tuple[float, float] | - tuple[npt.NDArray, npt.NDArray] -): + ret_data: str = "avg,sd" + ) -> (float | + npt.NDArray | + tuple[float, float] | + tuple[npt.NDArray, npt.NDArray]): """Compute avg and/or std of the event brightness The event brightness is defined by the gray-scale values of the @@ -28,7 +27,7 @@ def get_bright(mask: npt.NDArray[bool] | list[npt.NDArray[bool]], image: ndarray or list of ndarrays of shape (M,N) A 2D array that holds the image in form of grayscale values of an event. - ret_data: str + ret_data A comma-separated list of metrices to compute - "avg": compute the average - "sd": compute the standard deviation diff --git a/dclab/features/bright_bc.py b/dclab/features/bright_bc.py index 3feb89fd..59b8ef97 100644 --- a/dclab/features/bright_bc.py +++ b/dclab/features/bright_bc.py @@ -12,12 +12,11 @@ def get_bright_bc(mask: npt.NDArray[bool] | list[npt.NDArray[bool]], image: npt.NDArray | list[npt.NDArray], image_bg: npt.NDArray | list[npt.NDArray], bg_off: float | npt.NDArray = None, - ret_data: str = "avg,sd") -> ( - float | - npt.NDArray | - tuple[float, float] | - tuple[npt.NDArray, npt.NDArray] -): + ret_data: str = "avg,sd" + ) -> (float | + npt.NDArray | + tuple[float, float] | + tuple[npt.NDArray, npt.NDArray]): """Compute avg and/or std of the background-corrected event brightness The background-corrected event brightness is defined by the @@ -36,7 +35,7 @@ def get_bright_bc(mask: npt.NDArray[bool] | list[npt.NDArray[bool]], bg_off: float or 1D ndarray Additional offset value that is added to `image_bg` before background correction - ret_data: str + ret_data A comma-separated list of metrices to compute - "avg": compute the average - "sd": compute the standard deviation diff --git a/dclab/features/bright_perc.py b/dclab/features/bright_perc.py index 0fdc2c8e..f7d267cd 100644 --- a/dclab/features/bright_perc.py +++ b/dclab/features/bright_perc.py @@ -11,10 +11,9 @@ def get_bright_perc(mask: npt.NDArray[bool] | list[npt.NDArray[bool]], image: npt.NDArray | list[npt.NDArray], image_bg: npt.NDArray | list[npt.NDArray], - bg_off: float | npt.NDArray = None) -> ( - tuple[float, float] | - tuple[npt.NDArray, npt.NDArray] -): + bg_off: float | npt.NDArray = None + ) -> (tuple[float, float] | + tuple[npt.NDArray, npt.NDArray]): """Compute 10th and 90th percentile of the bg-corrected event brightness The background-corrected event brightness is defined by the diff --git a/dclab/features/fl_crosstalk.py b/dclab/features/fl_crosstalk.py index c4db8127..fa6dee67 100644 --- a/dclab/features/fl_crosstalk.py +++ b/dclab/features/fl_crosstalk.py @@ -22,12 +22,12 @@ def get_compensation_matrix( Parameters ---------- - cij: float + cij Spill from channel i to channel j Returns ------- - inv: np.ndarray + inv Compensation matrix (inverted spillover matrix) """ ct11 = 1 @@ -70,12 +70,12 @@ def correct_crosstalk( Parameters ---------- - fli: int, float, or np.ndarray + fli Measured fluorescence signals - fl_channel: int (1, 2, or 3) - The channel number for which the crosstalk-corrected signal - should be computed - cij: float + fl_channel + The channel number (1, 2, or 3) for which the crosstalk-corrected + signal should be computed + cij Spill (crosstalk or bleed-through) from channel i to channel j This spill is computed from the fluorescence signal of e.g. single-stained positive control cells; It is defined by the diff --git a/dclab/features/inert_ratio.py b/dclab/features/inert_ratio.py index a70b7b29..a895716f 100644 --- a/dclab/features/inert_ratio.py +++ b/dclab/features/inert_ratio.py @@ -16,11 +16,11 @@ def cont_moments_cv(cont: npt.NDArray, Parameters ---------- - cont: array of shape (N,2) + cont: shape (N,2) The contour for which to compute the moments. - flt_epsilon: float + flt_epsilon The value of ``FLT_EPSILON`` in OpenCV/gcc. - dbl_epsilon: float + dbl_epsilon The value of ``DBL_EPSILON`` in OpenCV/gcc. .. versionchanged:: 0.48.2 @@ -31,7 +31,7 @@ def cont_moments_cv(cont: npt.NDArray, Returns ------- - moments: dict + moments A dictionary of moments. If the moment `m00` is smaller than half of `flt_epsilon`, `None` is returned. """ diff --git a/dclab/features/volume.py b/dclab/features/volume.py index 873b859c..b441e641 100644 --- a/dclab/features/volume.py +++ b/dclab/features/volume.py @@ -28,10 +28,10 @@ def get_volume( pos_y: float or ndarray of length N The y coordinate(s) of the centroid of the event(s) [µm] e.g. obtained using `mm.pos_y` - pix: float + pix The detector pixel size in µm. e.g. obtained using: `mm.config["imaging"]["pixel size"]` - fix_orientation: bool + fix_orientation If set to True, make sure that the orientation of the contour is counter-clockwise in the r-z plane (see :func:`vol_revolve`). This is False by default, because @@ -42,7 +42,7 @@ def get_volume( Returns ------- - volume: float or ndarray + volume volume in um^3 Notes @@ -133,17 +133,17 @@ def get_volume( return v_avg -def counter_clockwise(cx: npt.NDArray, cy: npt.NDArray) -> float: +def counter_clockwise(cx: npt.NDArray, cy: npt.NDArray) -> tuple[float, float]: """Put contour coordinates into counter-clockwise order Parameters ---------- - cx, cy: 1d ndarrays + cx, cy The x- and y-coordinates of the contour Returns ------- - cx_cc, cy_cc: + cx_cc, cy_cc The x- and y-coordinates of the contour in counter-clockwise orientation. @@ -160,7 +160,9 @@ def counter_clockwise(cx: npt.NDArray, cy: npt.NDArray) -> float: return cx, cy -def vol_revolve(r: npt.NDArray, z: npt.NDArray, point_scale: float = 1.): +def vol_revolve(r: npt.NDArray, + z: npt.NDArray, + point_scale: float = 1.) -> float | npt.NDArray: r"""Calculate the volume of a polygon revolved around the Z-axis This implementation yields the same results as the volRevolve @@ -191,11 +193,11 @@ def vol_revolve(r: npt.NDArray, z: npt.NDArray, point_scale: float = 1.): Parameters ---------- - r: 1d np.ndarray + r radial coordinates (perpendicular to the z axis) - z: 1d np.ndarray + z coordinate along the axis of rotation - point_scale: float + point_scale point size in your preferred units; The volume is multiplied by a factor of `point_scale**3`.