Skip to content

Commit

Permalink
ref: docstrings - remove duplicate info but keep array shape info
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoghan O'Connell committed Nov 27, 2024
1 parent 63905bf commit e49eba0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 39 deletions.
13 changes: 6 additions & 7 deletions dclab/features/bright.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions dclab/features/bright_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions dclab/features/bright_perc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions dclab/features/fl_crosstalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions dclab/features/inert_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
"""
Expand Down
22 changes: 12 additions & 10 deletions dclab/features/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,7 +42,7 @@ def get_volume(
Returns
-------
volume: float or ndarray
volume
volume in um^3
Notes
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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`.
Expand Down

0 comments on commit e49eba0

Please sign in to comment.