Skip to content

Simplify - #13

Merged
jsture merged 14 commits into
mainfrom
simplify
Jul 2, 2026
Merged

Simplify#13
jsture merged 14 commits into
mainfrom
simplify

Conversation

@jsture

@jsture jsture commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Checklist

  • Tests added or updated for the change
  • parametrize_with_checks (tests/test_sklearn_compat.py) still passes
  • numpydoc docstrings added/updated for any public API
  • uv run ruff check and uv run ruff format --check pass
  • uv run pyright src passes
  • Changelog entry added to CHANGES.md
  • Public-API impact noted below (new/changed/removed params, methods)

Public-API impact

jsture added 3 commits July 1, 2026 09:07
component_explained_x_variance and explained_x_variance had diverging
shape-check logic; align them on the same 2D/shape validation and
trim redundant docstrings.
fit() was one long method and predict/transform/score_distance/
q_residuals each re-derived Xs/X_filtered/scores via separate,
overlapping reconstruction helpers. Introduce _OPLSProjection and
_project_validated() as the single path for scaling + orthogonal
filtering + predictive transform, and split fit() into named steps.
Update OPLSDA to go through the new projection helper too.
Plotting display from_estimator() silently unwrapped
GridSearchCV/other search meta-estimators via best_estimator_. That
special case only handled the two-attribute shape and hid which model
was actually being plotted. Require callers to pass
search.best_estimator_ explicitly; plotting now only accepts OPLS,
OPLSDA, or a pipeline ending in one.

BREAKING CHANGE: passing a fitted search meta-estimator directly to
OPLSScoresDisplay.from_estimator/SPlotDisplay.from_estimator now
raises TypeError.
@jsture jsture self-assigned this Jul 1, 2026
jsture added 3 commits July 1, 2026 09:19
… _stack_columns, cache _ssq in orthogonal extraction, add all-scale predict and multi-output score tests

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR simplifies and consolidates internal validation/projection logic across the library, while tightening plotting support to require explicit base estimators (or pipelines) rather than accepting search meta-estimators directly.

Changes:

  • Centralizes integer validation (including explicit bool rejection) via new _utils helpers and reuses them across modules.
  • Refactors OPLS projection/reconstruction paths around a single _project_validated() flow and updates plotting to consume it.
  • Updates plotting and docs/tests to no longer accept GridSearchCV directly (requiring best_estimator_), and tightens permutation_test response-shape validation.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_plotting.py Updates plotting tests to require best_estimator_ for search wrappers and to assert clearer error behavior.
tests/test_o2pls.py Adds regression tests around multi-output scoring and prediction equivalences across scaling modes.
src/scikit_opls/validation.py Reuses _validate_int and enforces 1D y in permutation_test.
src/scikit_opls/plotting.py Removes search-estimator unwrapping and switches score/S-plot computations to _project_validated().
src/scikit_opls/_utils.py Adds shared helpers _reject_bool_param and _validate_int.
src/scikit_opls/_orthogonal.py Replaces local int validation with _validate_int and simplifies tolerance checks.
src/scikit_opls/_opls.py Refactors fit() into smaller helpers and introduces _OPLSProjection / _project_validated() for shared projections.
src/scikit_opls/_opls_da.py Reuses _reject_bool_param and routes prediction through _project_validated().
src/scikit_opls/_o2pls.py Reuses _reject_bool_param for bool-rejection of integral hyperparameters.
src/scikit_opls/_o2pls_core.py Reuses _validate_int and simplifies internal stacking/diagnostic calculations and docstrings.
src/scikit_opls/_inspection.py Tightens shape checks and simplifies explained-variance computations for fitted arrays.
README.md Updates plotting guidance to require explicit search.best_estimator_ for tuned models.
docs/quickstart.md Mirrors README plotting guidance change for tuned models (best_estimator_).

Comment thread src/scikit_opls/validation.py Outdated
Comment thread src/scikit_opls/_opls.py Outdated
@jsture
jsture merged commit a078215 into main Jul 2, 2026
2 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants