From 2d68f3407b73952daf030caed677e614525d1a75 Mon Sep 17 00:00:00 2001 From: Daniel Eddie Rollins Date: Fri, 6 Mar 2026 17:02:59 +0000 Subject: [PATCH 1/2] Add __version__ numbers to public 'apply_' funciton and 'get_background'. Start all at 0.1.0 --- src/pnanolocz/level.py | 21 ++++++++++++++++++--- src/pnanolocz/level_auto.py | 7 +++++++ src/pnanolocz/level_weighted.py | 11 +++++++++-- src/pnanolocz/thresholder.py | 7 +++++++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/pnanolocz/level.py b/src/pnanolocz/level.py index 2fb69ab..c68748d 100644 --- a/src/pnanolocz/level.py +++ b/src/pnanolocz/level.py @@ -7,7 +7,7 @@ row- or column-wise artefacts commonly observed in AFM topographic data. All public leveling functions accept an *exclusion mask* (same convention as -``pnanolocz_lib.thresholder``): ``True`` = excluded, ``False`` = valid. +``pnanolocz.thresholder``): ``True`` = excluded, ``False`` = valid. Excluded pixels are omitted from fitting using MATLAB-style NaN-outside semantics (i.e., excluded pixels behave like NaN during fitting) but are preserved in the output array. @@ -63,10 +63,10 @@ Examples -------- ->>> from pnanolocz_lib.level import level +>>> from pnanolocz.level import level >>> leveled_stack = apply_level(stack, polyx=2, polyy=2, method="plane") ->>> from pnanolocz_lib.level import level_plane +>>> from pnanolocz.level import level_plane >>> flattened = level_plane(img, mask=None, polyx=2, polyy=2) Authors @@ -845,6 +845,10 @@ def apply_level( operations (e.g. ``where(valid, value, nan)``) during fitting. - Method-specific MATLAB parity notes (e.g., stage gating such as `polyy > 0` in ``"line"``) are documented in the corresponding function docstrings. + + Version + ------- + 0.1.0 """ img = np.asarray(img) is_stack = img.ndim == 3 @@ -921,6 +925,9 @@ def apply_level( return np.asarray(result) if is_stack else np.asarray(result[0]) +apply_level.__version__ = "0.1.0" + + def get_background( img: np.ndarray[Any, np.dtype[np.float64]], polyx: int, @@ -982,6 +989,10 @@ def get_background( certain parameter values) are inherited here. - Excluded pixels are preserved in the output arrays; masking primarily affects which pixels contribute to fitted estimates. + + Version + ------- + 0.1.0 """ img = np.asarray(img) is_stack = img.ndim == 3 @@ -1028,6 +1039,9 @@ def get_background( return np.asarray(result) if is_stack else np.asarray(result[0]) +get_background.__version__ = "0.1.0" + + __all__ = [ "apply_level", "level_plane", @@ -1037,4 +1051,5 @@ def get_background( "level_smed_line", "level_mean_plane", "level_log_y", + "get_background", ] diff --git a/src/pnanolocz/level_auto.py b/src/pnanolocz/level_auto.py index c944d98..b4e16dd 100644 --- a/src/pnanolocz/level_auto.py +++ b/src/pnanolocz/level_auto.py @@ -972,6 +972,10 @@ def apply_level_auto( ``_compute_gauss_limits`` when a thresholder step declares ``args=['gauss_*']``. - The Gaussian-derived histogram bounds are calculated for each frame rather than globally across the stack, diverging from MATLAB behavior. + + Version + ------- + 0.1.0 """ img_stack = np.asarray(img_stack) if img_stack.ndim == 2: @@ -1041,4 +1045,7 @@ def apply_level_auto( return np.asarray(result[0]) if was_2d else np.asarray(result) +apply_level_auto.__version__ = "0.1.0" + + __all__ = ["apply_level_auto", "ROUTINES"] diff --git a/src/pnanolocz/level_weighted.py b/src/pnanolocz/level_weighted.py index 3dda92b..94cbe33 100644 --- a/src/pnanolocz/level_weighted.py +++ b/src/pnanolocz/level_weighted.py @@ -8,7 +8,7 @@ and non-uniform masking effects. All public leveling functions accept an *exclusion mask* (same convention as -``pnanolocz_lib.thresholder``): ``True`` = excluded, ``False`` = valid. Excluded +``pnanolocz.thresholder``): ``True`` = excluded, ``False`` = valid. Excluded pixels are omitted from region formation and fitting using MATLAB-style NaN-outside semantics (i.e., excluded pixels behave like NaN during fitting) but are preserved in the output array. @@ -55,7 +55,7 @@ Examples -------- ->>> from pnanolocz_lib.level_weighted import apply_level_weighted +>>> from pnanolocz.level_weighted import apply_level_weighted >>> leveled = apply_level_weighted(img, polyx=2, polyy=1, method='plane', mask=mask) Authors @@ -849,6 +849,10 @@ def apply_level_weighted( ``bwconncomp(mask, 8)``. - A MATLAB-style minimum region area is enforced via: ``min_area = max(1, floor(0.01 * H * W))``. + + Version + ------- + 0.1.0 """ arr = np.asarray(img, dtype=np.float64) is_stack = arr.ndim == 3 @@ -897,6 +901,9 @@ def apply_level_weighted( return np.asarray(stacked if is_stack else stacked[0]) +apply_level_weighted.__version__ = "0.1.0" + + __all__ = [ "apply_level_weighted", "level_weighted_plane", diff --git a/src/pnanolocz/thresholder.py b/src/pnanolocz/thresholder.py index 63b3454..7943c15 100644 --- a/src/pnanolocz/thresholder.py +++ b/src/pnanolocz/thresholder.py @@ -1027,6 +1027,10 @@ def apply_thresholder( >>> # Otsu on a stack, then invert to obtain a validity mask (True = valid) >>> excl = apply_thresholder(stack, method="otsu") >>> valid = np.logical_not(excl) + + Version + ------- + 0.1.0 """ method = method.lower() if method not in _METHOD_MAP: @@ -1069,6 +1073,9 @@ def apply_thresholder( return result +apply_thresholder.__version__ = "0.1.0" + + __all__ = [ "apply_thresholder", "selection", From 517cad9ac80e9f6c8255d92ccc2231232d45543b Mon Sep 17 00:00:00 2001 From: Daniel Eddie Rollins Date: Fri, 6 Mar 2026 17:31:06 +0000 Subject: [PATCH 2/2] Add # type: ignore[attr-defined] to /__version__ attributes on functions --- src/pnanolocz/level.py | 4 ++-- src/pnanolocz/level_auto.py | 2 +- src/pnanolocz/level_weighted.py | 2 +- src/pnanolocz/thresholder.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pnanolocz/level.py b/src/pnanolocz/level.py index c68748d..5b12405 100644 --- a/src/pnanolocz/level.py +++ b/src/pnanolocz/level.py @@ -925,7 +925,7 @@ def apply_level( return np.asarray(result) if is_stack else np.asarray(result[0]) -apply_level.__version__ = "0.1.0" +apply_level.__version__ = "0.1.0" # type: ignore[attr-defined] def get_background( @@ -1039,7 +1039,7 @@ def get_background( return np.asarray(result) if is_stack else np.asarray(result[0]) -get_background.__version__ = "0.1.0" +get_background.__version__ = "0.1.0" # type: ignore[attr-defined] __all__ = [ diff --git a/src/pnanolocz/level_auto.py b/src/pnanolocz/level_auto.py index b4e16dd..a4a15ed 100644 --- a/src/pnanolocz/level_auto.py +++ b/src/pnanolocz/level_auto.py @@ -1045,7 +1045,7 @@ def apply_level_auto( return np.asarray(result[0]) if was_2d else np.asarray(result) -apply_level_auto.__version__ = "0.1.0" +apply_level_auto.__version__ = "0.1.0" # type: ignore[attr-defined] __all__ = ["apply_level_auto", "ROUTINES"] diff --git a/src/pnanolocz/level_weighted.py b/src/pnanolocz/level_weighted.py index 94cbe33..4c80dbc 100644 --- a/src/pnanolocz/level_weighted.py +++ b/src/pnanolocz/level_weighted.py @@ -901,7 +901,7 @@ def apply_level_weighted( return np.asarray(stacked if is_stack else stacked[0]) -apply_level_weighted.__version__ = "0.1.0" +apply_level_weighted.__version__ = "0.1.0" # type: ignore[attr-defined] __all__ = [ diff --git a/src/pnanolocz/thresholder.py b/src/pnanolocz/thresholder.py index 7943c15..35f1058 100644 --- a/src/pnanolocz/thresholder.py +++ b/src/pnanolocz/thresholder.py @@ -1073,7 +1073,7 @@ def apply_thresholder( return result -apply_thresholder.__version__ = "0.1.0" +apply_thresholder.__version__ = "0.1.0" # type: ignore[attr-defined] __all__ = [