Skip to content

Commit

Permalink
docs: add futures annotations import for older py versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Eoghan O'Connell committed Nov 26, 2024
1 parent 1c4d9c1 commit 821b4b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions dclab/features/bright.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Computation of mean and standard deviation of grayscale values inside the
RT-DC event image mask.
"""
from __future__ import annotations

import numpy as np
import numpy.typing as npt

Expand Down
9 changes: 8 additions & 1 deletion dclab/features/bright_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
Computation of mean and standard deviation of grayscale values inside the
RT-DC event image mask with background-correction taken into account.
"""
from __future__ import annotations

import numpy as np
import numpy.typing as npt


def get_bright_bc(mask, image, image_bg, bg_off=None, ret_data="avg,sd"):
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"):
"""Compute avg and/or std of the background-corrected event brightness
The background-corrected event brightness is defined by the
Expand Down
2 changes: 2 additions & 0 deletions dclab/features/bright_perc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Computation of the 10th and 90th percentile of grayscale values inside the
RT-DC event image mask with background-correction taken into account.
"""
from __future__ import annotations

import numpy as np
import numpy.typing as npt

Expand Down
9 changes: 6 additions & 3 deletions dclab/features/contour.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Computation of event contour from event mask"""
from __future__ import annotations

from collections import deque
import numbers

import numpy as np
import numpy.typing as npt

# equivalent to
# from skimage.measure import find_contours
Expand All @@ -14,15 +17,15 @@ class NoValidContourFoundError(BaseException):


class LazyContourList(object):
def __init__(self, masks, max_events=1000):
def __init__(self, masks: npt.ArrayLike, max_events: int = 1000):
"""A list-like object that computes contours upon indexing
Parameters
----------
masks: array-like
masks
3D array of masks, may be an HDF5 dataset or any other
structure that supports indexing
max_events: int
max_events
maximum number of contours to keep in the contour list;
set to 0/False/None to cache all contours
Expand Down

0 comments on commit 821b4b3

Please sign in to comment.