diff --git a/.markdownlint.yaml b/.markdownlint.yaml index f651c3c..b3b5791 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -6,3 +6,8 @@ MD013: MD033: allowed_elements: - div + +# Exclude files +ignore: + - LICENSE + - LICENSE.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62ed8e3..b6fe3d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: hooks: - id: black language_version: python3 - exclude: (^docs/|^notebooks/|^LICENSE$) + exclude: (^docs/|^notebooks/|^LICENSE$|build/) # --- Mypy (type checking) --- - repo: https://github.com/pre-commit/mirrors-mypy diff --git a/pyproject.toml b/pyproject.toml index facb65a..3cbcbc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "pnanolocz_lib" description = "A Python library for AFM, HS-AFM, and Localization AFM data analysis. Based on NanoLocz" authors = [ { name = "George Heath", email = "G.R.Heath@leeds.ac.uk" }, - { name = "D. E. Rollins", email = "d.e.rollins@leeds.ac.uk" } + { name = "Daniel E. Rollins", email = "d.e.rollins@leeds.ac.uk" } ] dynamic = ["version"] readme = "README.md" diff --git a/src/pnanolocz_lib/level.py b/src/pnanolocz_lib/level.py index c56c05f..2fb69ab 100644 --- a/src/pnanolocz_lib/level.py +++ b/src/pnanolocz_lib/level.py @@ -82,7 +82,6 @@ from typing import Any, Literal, Optional import numpy as np -from numpy.polynomial.polyutils import RankWarning # type: ignore[attr-defined] from scipy.optimize import curve_fit # Constants @@ -193,7 +192,8 @@ def level_plane( # ========== X DIRECTION ========== # Column-wise masked mean with NaN-outside semantics with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=RuntimeWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") column_means = np.nanmean(np.where(m, arr, np.nan), axis=0) valid_columns = ~np.isnan(column_means) @@ -213,7 +213,8 @@ def level_plane( standardized_columns = (column_indices - col_centroid) / col_scale with warnings.catch_warnings(): - warnings.simplefilter("ignore", RankWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") x_coeffs = np.polyfit(standardized_columns, column_means[valid_columns], polyx) # Evaluate polynomial at every column (1..W) using the same mu @@ -226,7 +227,8 @@ def level_plane( # ========== Y DIRECTION ========== # Row-wise masked mean after X subtraction (NaN-outside semantics) with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=RuntimeWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") row_means = np.nanmean(np.where(m, leveled, np.nan), axis=1) valid_rows = ~np.isnan(row_means) @@ -245,7 +247,8 @@ def level_plane( standardized_rows = (row_indices - row_centroid) / row_scale with warnings.catch_warnings(): - warnings.simplefilter("ignore", RankWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") y_coeffs = np.polyfit(standardized_rows, row_means[valid_rows], polyy) # Evaluate polynomial at every row (1..H) with the same mu @@ -333,7 +336,8 @@ def level_line( xs = (x_idx - mu) / sd # xs: standardized x indices used for fitting with warnings.catch_warnings(): - warnings.simplefilter("ignore", RankWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") p_coeff = np.polyfit(xs, y_vals, polyx) all_cols = (np.arange(img_width) + 1).astype(np.float64) @@ -378,7 +382,8 @@ def level_line( ys = (yl - mu) / sd # ys: standardized y indices used for fitting with warnings.catch_warnings(): - warnings.simplefilter("ignore", RankWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") p_coeff = np.polyfit(ys, y_vals, polyy) all_rows = (np.arange(img_height) + 1).astype(np.float64) diff --git a/src/pnanolocz_lib/level_weighted.py b/src/pnanolocz_lib/level_weighted.py index 5d3dbdd..3dda92b 100644 --- a/src/pnanolocz_lib/level_weighted.py +++ b/src/pnanolocz_lib/level_weighted.py @@ -70,7 +70,6 @@ from typing import Any, List, Optional, Tuple import numpy as np -from numpy.polynomial.polyutils import RankWarning # type: ignore[attr-defined] from scipy import ndimage # --------------------- @@ -151,7 +150,8 @@ def _polyfit_centered( std_x = (x - centroid) / scale with warnings.catch_warnings(): - warnings.simplefilter("ignore", RankWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") coeffs = np.polyfit(std_x, y, order) return np.asarray(coeffs, dtype=np.float64), (centroid, scale) @@ -314,7 +314,8 @@ def level_weighted_plane( # X-direction: mean of each column within region with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=RuntimeWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") mean_by_col = np.nanmean( region_masked, axis=0 ) # Nanolocz-mean_by_col is xp @@ -336,7 +337,8 @@ def level_weighted_plane( # Y-direction: mean of each row within region with warnings.catch_warnings(): - warnings.simplefilter("ignore", category=RuntimeWarning) + warnings.simplefilter("ignore", RuntimeWarning) + warnings.filterwarnings("ignore", message=".*[Rr]ank.*") mean_by_row = np.nanmean(region_masked, axis=1) valid_rows = ~np.isnan(mean_by_row) row_values = mean_by_row[valid_rows] diff --git a/src/pnanolocz_lib/thresholder.py b/src/pnanolocz_lib/thresholder.py index 88f86ef..63b3454 100644 --- a/src/pnanolocz_lib/thresholder.py +++ b/src/pnanolocz_lib/thresholder.py @@ -73,7 +73,7 @@ Authors ------- George Heath, University of Leeds (MATLAB reference implementation) -D. E. Rollins, University of Leeds (Python implementation) +Daniel E. Rollins, University of Leeds (Python implementation) Part of the pNanoLocz-Lib Python library for AFM analysis. """