From bb1e11a95dc7294d3de0bf4cf13658cac37f9664 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 31 Jul 2026 07:10:14 +0000 Subject: [PATCH 1/3] plan: docstring/code consistency audit Auditing computational/user-facing docstrings across multivariate, experiments, monitoring, regression, univariate, and batch modules for real inconsistencies (wrong params, wrong return shape, stale examples, missing/removed exception mentions, etc.). From 8e7503bf75902a8704263ae6d7b96ba5a30b4590 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 31 Jul 2026 07:18:46 +0000 Subject: [PATCH 2/3] docs(multivariate): fix real docstring/code inconsistencies - PCA.select_n_components: document the ``return_consensus`` parameter (used but missing from Parameters) and the four extra Bunch keys it attaches to the return value (``minka_n_components``, ``parallel_analysis_n_components``, ``consensus``, ``consensus_counts``). - PLS.select_n_components: complete the ``selection_mode`` bullet in the Returns section; the sentence ended abruptly ("or ``None`` when ``selection_distribution`` is.") -> "... is ``None``.". No code behaviour changes. Co-Authored-By: Claude Opus 4.7 (1M context) Claude-Session: https://claude.ai/code/session_01TikjthFYE6JPHA38JkXzub --- src/process_improve/multivariate/_pca.py | 20 ++++++++++++++++++++ src/process_improve/multivariate/_pls.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/process_improve/multivariate/_pca.py b/src/process_improve/multivariate/_pca.py index ca6cb4b2..fcbe7230 100644 --- a/src/process_improve/multivariate/_pca.py +++ b/src/process_improve/multivariate/_pca.py @@ -1074,6 +1074,14 @@ def select_n_components( # noqa: PLR0913, PLR0915, C901 emits a :class:`DeprecationWarning`; the value is ignored. Use ``selection_rule="q2_increment"`` (and tune ``min_q2_increase``) for a comparable parsimony preference. + return_consensus : bool, default False + When ``True``, also run :meth:`minka_mle` and + :meth:`parallel_analysis` on ``X`` and attach their + recommendations to the returned Bunch alongside the ekf choice + (see the ``minka_n_components`` / + ``parallel_analysis_n_components`` / ``consensus`` / + ``consensus_counts`` fields below). Off by default because the + two extra estimates require their own eigendecomposition. **pca_kwargs Additional keyword arguments passed to the ``PCA()`` constructor under ``cv_scheme="row_wise"`` (e.g. ``algorithm="nipals"``). @@ -1108,6 +1116,18 @@ def select_n_components( # noqa: PLR0913, PLR0915, C901 - ``cv_scheme`` - the scheme used (``"ekf"`` or ``"row_wise"``). - ``selection_rule`` - the rule used to pick ``n_components``. + When ``return_consensus=True`` the Bunch also carries four + extra keys sourced from the cheap cross-checks: + + - ``minka_n_components`` - :meth:`minka_mle` estimate (int). + - ``parallel_analysis_n_components`` - + :meth:`parallel_analysis` estimate (int). + - ``consensus`` - ``"agree"`` when the three recommendations + lie within one component of one another, ``"disagree"`` + otherwise. + - ``consensus_counts`` - the three recommendations as a + ``(ekf, minka, parallel_analysis)`` tuple. + References ---------- Bro, R., Kjeldahl, K., Smilde, A. K., & Kiers, H. A. L. (2008). diff --git a/src/process_improve/multivariate/_pls.py b/src/process_improve/multivariate/_pls.py index 9cd41b36..fdacf095 100644 --- a/src/process_improve/multivariate/_pls.py +++ b/src/process_improve/multivariate/_pls.py @@ -1308,7 +1308,7 @@ def select_n_components( # noqa: C901, PLR0912, PLR0913, PLR0915 distribution signals a confident recommendation; a flat or multi-modal one flags it for review. - ``selection_mode`` - the most-voted component count, or - ``None`` when ``selection_distribution`` is. + ``None`` when ``selection_distribution`` is ``None``. - ``selection_is_stable`` - ``True`` iff the modal vote share meets ``stability_threshold``; ``None`` when no distribution was computed. From 201d25b3022c8f528a10ea0bc08b5ededd54a506 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 31 Jul 2026 07:19:30 +0000 Subject: [PATCH 3/3] chore(release): bump version to 1.62.3 PATCH bump: docstring-only fixes to PCA.select_n_components and PLS.select_n_components (see CHANGELOG). Sync CITATION.cff to match. Co-Authored-By: Claude Opus 4.7 (1M context) Claude-Session: https://claude.ai/code/session_01TikjthFYE6JPHA38JkXzub --- CHANGELOG.md | 16 +++++++++++++++- CITATION.cff | 4 ++-- pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85b64d49..e2a7d508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,19 @@ those changes. ## [Unreleased] +## [1.62.3] - 2026-07-31 + +### Fixed + +- Docstrings: `PCA.select_n_components` now documents the + `return_consensus` parameter (previously present in the signature but + missing from the Parameters section) and the four extra Bunch keys it + attaches (`minka_n_components`, `parallel_analysis_n_components`, + `consensus`, `consensus_counts`). +- Docstring: `PLS.select_n_components` `selection_mode` bullet in the + Returns section had a truncated sentence ("or `None` when + `selection_distribution` is."); completed to "... is `None`.". + ## [1.62.2] - 2026-07-29 ### Changed @@ -2787,7 +2800,8 @@ this entry records them together. - Reworked the README with a sharper value proposition and a "Why not scikit-learn?" comparison table. -[Unreleased]: https://github.com/kgdunn/process-improve/compare/v1.62.2...HEAD +[Unreleased]: https://github.com/kgdunn/process-improve/compare/v1.62.3...HEAD +[1.62.3]: https://github.com/kgdunn/process-improve/compare/v1.62.2...v1.62.3 [1.62.2]: https://github.com/kgdunn/process-improve/compare/v1.62.1...v1.62.2 [1.62.1]: https://github.com/kgdunn/process-improve/compare/v1.62.0...v1.62.1 [1.62.0]: https://github.com/kgdunn/process-improve/compare/v1.61.0...v1.62.0 diff --git a/CITATION.cff b/CITATION.cff index 17f25a94..f937d379 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -12,8 +12,8 @@ authors: repository-code: "https://github.com/kgdunn/process-improve" url: "https://kgdunn.github.io/process-improve/" license: MIT -version: 1.62.2 -date-released: "2026-07-29" +version: 1.62.3 +date-released: "2026-07-31" keywords: - chemometrics - multivariate analysis diff --git a/pyproject.toml b/pyproject.toml index 4aba40f6..5ec03b87 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "process-improve" -version = "1.62.2" +version = "1.62.3" description = 'Designed Experiments; Latent Variables (PCA, PLS, multivariate methods with missing data); Process Monitoring; Batch data analysis.' readme = "README.md" license = "MIT"