From a40c4fca6a562b3c831f7f802036adee710d6829 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 07:19:33 +0000 Subject: [PATCH] docs: fix five docstring drift issues in schemas/core/db/api --- pyproject.toml | 2 +- src/scorepilot/api/models.py | 9 +++++---- src/scorepilot/core/profiling.py | 5 +++-- src/scorepilot/core/transforms.py | 4 +++- src/scorepilot/db/models.py | 9 +++++---- src/scorepilot/schemas.py | 5 +++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8e22790..9ccca90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "scorepilot" -version = "0.22.0" +version = "0.22.1" description = "Web-based tool for PCA/PLS model analysis in chemometrics." readme = "README.md" requires-python = ">=3.12" diff --git a/src/scorepilot/api/models.py b/src/scorepilot/api/models.py index 8259349..3010d89 100644 --- a/src/scorepilot/api/models.py +++ b/src/scorepilot/api/models.py @@ -334,7 +334,8 @@ def get_model( """Return a model's Logbook: metadata, recipe, lineage, and diagnostics. Diagnostics are recomputed from the source dataset and stored spec. If the - dataset is no longer in memory, the entry is returned without diagnostics. + dataset is no longer available (the source dataset record is missing or + deleted), the entry is returned without diagnostics. ``n_components`` previews the diagnostics at a different component count without persisting it - this backs the live component explorer, which scrubs @@ -383,7 +384,7 @@ def update_model( if dataset is None: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, - detail="Source dataset is no longer loaded; cannot refit.", + detail="Source dataset is no longer available; cannot refit.", ) spec = PreprocessingSpec.from_dict(model.preprocessing) @@ -424,7 +425,7 @@ def model_contributions( if dataset is None: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, - detail="Source dataset is no longer loaded; cannot compute contributions.", + detail="Source dataset is no longer available; cannot compute contributions.", ) spec = PreprocessingSpec.from_dict(model.preprocessing) @@ -486,7 +487,7 @@ def model_cross_validation( if dataset is None: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, - detail="Source dataset is no longer loaded; cannot cross-validate.", + detail="Source dataset is no longer available; cannot cross-validate.", ) ceiling = min(max_components or model.n_components, _AUTO_MAX_COMPONENTS) diff --git a/src/scorepilot/core/profiling.py b/src/scorepilot/core/profiling.py index 74f0540..80c62d0 100644 --- a/src/scorepilot/core/profiling.py +++ b/src/scorepilot/core/profiling.py @@ -143,8 +143,9 @@ def suggest_transform(summary: VariableSummary) -> TransformKind: """Suggest a transform from a variable's shape. A strongly right-skewed, strictly positive variable with a wide dynamic range - is a candidate for a log transform; a milder skew suggests a signed power - (root). Otherwise no transform is suggested. + is a candidate for a log transform; a strong skew that isn't positive with a + wide dynamic range suggests a signed power (root). Otherwise no transform is + suggested. """ if summary.column_type is not ColumnType.QUANTITATIVE or summary.skewness is None: return TransformKind.NONE diff --git a/src/scorepilot/core/transforms.py b/src/scorepilot/core/transforms.py index 80a2ab2..cd59c95 100644 --- a/src/scorepilot/core/transforms.py +++ b/src/scorepilot/core/transforms.py @@ -48,7 +48,9 @@ def apply_transform( - ``neglog``: ``sign(x) * log1p(abs(x))`` (sign-symmetric log) - ``logit``: ``log(p / (1 - p))`` with ``p = x`` (defined for ``0 < x < 1``) - ``exponential``: ``exp(x)`` - - ``power``: ``sign(x) * abs(x) ** c1`` (default ``c1 = 0.5``, i.e. signed root) + - ``power``: ``sign(x) * abs(x) ** c1``. The parameter default is + ``c1=0.0``, which ``_transform_values`` remaps internally to ``0.5`` + (signed root); pass a non-zero ``c1`` to use it directly. """ values = to_numeric(series).astype(float).to_numpy() diff --git a/src/scorepilot/db/models.py b/src/scorepilot/db/models.py index 61b9bf6..11ee7dc 100644 --- a/src/scorepilot/db/models.py +++ b/src/scorepilot/db/models.py @@ -47,10 +47,11 @@ def __repr__(self) -> str: class Model(Base): """A fitted PCA/PLS model variant. - Queryable metadata lives in real columns and JSON; the fitted arrays (P, W, - means, scales, ...) are stored as a compressed ``npz`` blob in ``params``. If - those artifacts grow, ``params`` can be swapped for an object-storage path - behind the same repository method without changing anything upstream. + Queryable metadata lives in real columns and JSON; the fitted arrays + (``x_loadings``, ``explained_variance``, ``r2_cumulative``) are stored as a + compressed ``npz`` blob in ``params``. If those artifacts grow, ``params`` + can be swapped for an object-storage path behind the same repository method + without changing anything upstream. """ __tablename__ = "model" diff --git a/src/scorepilot/schemas.py b/src/scorepilot/schemas.py index cbcd5f6..2878411 100644 --- a/src/scorepilot/schemas.py +++ b/src/scorepilot/schemas.py @@ -302,8 +302,9 @@ class FitModelRequest(ApiModel): With ``auto_components`` the number of components is chosen by cross-validation via the selected ``selection_rule`` (the one-standard-error - rule for PLS and the lowest cross-validated error for PCA, by default), and - ``n_components`` is used only as an upper bound on what is evaluated. + rule for PLS and the lowest cross-validated error for PCA, by default). + When ``auto_components`` is set, the request's ``n_components`` is ignored; + cross-validation evaluates up to a fixed internal ceiling. """ dataset_id: str