Skip to content

Return self from optimizer parameter updates - #699

Open
Afloat16 wants to merge 1 commit into
dynamicslab:mainfrom
Afloat16:fix/optimizer-set-params-return-self-20261010
Open

Afloat16 wants to merge 1 commit into
dynamicslab:mainfrom
Afloat16:fix/optimizer-set-params-return-self-20261010

Conversation

@Afloat16

Copy link
Copy Markdown

Direct GridSearchCV over STLSQ calls set_params(...).fit(...), so returning None currently breaks the estimator protocol. This patch returns self from BaseOptimizer.set_params and TrappingSR3.set_params after their existing parameter-update behavior.

Six regressions cover empty and changed updates, direct and nested grid searches, and independently derived cross-validation scores. On the current upstream baseline c4421fcec275c8f4cc5c1e93bebb961b212067ae, the new cases give 5 failures and 1 passing control. With the patch, all 6 pass.

Validation on the three changed files:

  • Black 23.12.1: formatting unchanged.
  • Flake8 7.3.0 with the repository .flake8: no findings.
  • Reorder Python Imports 2.5.0: no changes.

Focused tests ran on CPython 3.12, NumPy 2.3.5, SciPy 1.17.0, scikit-learn 1.8.0, cvxpy 1.9.3 and pytest 7.4.4:

python -m pytest --noconftest test/test_optimizers/test_optimizer_set_params.py -q

The shared upstream conftest.py imports JAX, which was unavailable in this environment; these tests use no shared fixtures. The full optional test suite and documentation build were not run. Upstream CI is pending.

Preserve sklearn's estimator-return protocol in both optimizer
parameter-update overrides. Verify exact cross-validation scores, direct
and nested searches, and unchanged validation contracts.

This branch has not been deployed

No deployments
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.

1 participant