Skip to content

Remove deprecated code - #743

Draft
janosg wants to merge 5 commits into
mainfrom
remove-deprecated-code
Draft

janosg wants to merge 5 commits into
mainfrom
remove-deprecated-code

Conversation

@janosg

@janosg janosg commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

What problem do you want to solve?

Version 0.6.0 is the release in which everything that was deprecated in 0.5.0 (mostly through EP-02 and EP-03) is scheduled for removal. This PR removes the deprecated functionality, the deprecation machinery and the tests for deprecated behavior. The removed functionality is listed under "Breaking changes" in CHANGES.md.

Removed

  • optimagic/deprecations.py, optimagic/logging/read_log.py (OptimizeLogReader), estimagic/utilities.py, estimagic/batch_evaluators.py, the deprecated re-exports in estimagic/__init__.py and the deprecated decorator.
  • Deprecated arguments of minimize, maximize, first_derivative, second_derivative, estimate_ml, estimate_msm, slice_plot, count_free_params and check_constraints.
  • Dictionary constraints (including loc/query selection and FixedValueConstraint), dictionary outputs of objective functions and dictionaries of derivative functions.
  • Richardson extrapolation (richardson_extrapolation.py and its helpers in derivatives.py).
  • Deprecated attributes and dictionary access of OptimizeResult, MultistartInfo, History (except History.time and History.runtime, see below) and NumdiffResult, deprecated multistart options, the translation of old algorithm option names and None as batch evaluator.
  • tests/optimagic/test_deprecations.py and other tests of deprecated behavior.

Changed

  • pre_process_constraints moves to optimagic.constraints. Its tests that are not about dictionaries move to tests/optimagic/test_constraints.py.
  • ScalarFunctionValue, LeastSquaresFunctionValue and LikelihoodFunctionValue raise an InvalidFunctionError for a dictionary with the entries "contributions" or "root_contributions" (scalar functions also for "value"). Otherwise a function marked with mark.least_squares or mark.likelihood that still returns the old dictionary would be read as a pytree and silently give wrong results, e.g. minimize would minimize value**2 + sum(root_contributions**2). The check covers minimize, maximize, slice_plot and estimate_ml (which marks loglike as likelihood function itself) and its message is shown directly.
  • History.time and History.runtime are kept until 0.7.0. Since 0.5.2 they only warned that they "will be deprecated soon", without a version, so they were never scheduled for 0.6.0. They now warn that they will be removed in 0.7.0.
  • Tests and docs that still used deprecated features are ported to the current interface (nonlinear constraint tests, jax tests, benchmark fixtures, optimization and likelihood tutorials, API reference, explanation of optimizer tests).

Notes for review

  • Dots in algo_options keys (e.g. "stopping.maxfun") are still converted to underscores. This happened inside the deprecation code but was never deprecated.
  • generate_steps and finite_differences still support several steps per direction internally, while derivatives.py now always uses one. Simplifying them is left for a follow-up.
  • The now unreachable handling of fixed constraints with explicit values in check_constraints.py and consolidate_constraints.py is untouched, because both files are replaced by the pending constraints refactoring.
  • check_optimization_options rejects fun and fun_kwargs in optimize_options instead of the removed names.
  • Because old algorithm option names are not translated anymore, options that carry such a name (stopping_max_criterion_evaluations of nag_pybobyqa, convergence_relative_params_tolerance of pygmo_de) can now be set via algo_options. Modernize the fides and NAG wrappers and add wrapper standards with a wrap-optimizer skill #746 renames the option of nag_pybobyqa; the one of pygmo_de still has to be renamed in a follow-up.
  • Deprecations that EP-02 planned but that were never implemented with a warning (error_penalty, the noise and scaling arguments of get_benchmark_problems, a list of algorithms in run_benchmark) are not touched.

Validation

  • pixi run tests (full suite): 3119 passed, 108 skipped, 4 xfailed. After the review fixes (c3d2db5): 3218 passed, 280 skipped, 4 xfailed.
  • The jax tests do not run in the pixi environment on macOS. In a temporary environment with jax, pytest -m jax (84 passed) and test_jax_derivatives.py (5 passed) pass.
  • pixi run -e type-checking ty and all pre-commit hooks pass.
  • pixi run -e docs build-docs succeeds and executes all notebooks.
  • Not run locally: tests of Linux-only optimizers (e.g. TAO).

AI assistance

The change was implemented with Claude Code (finding the deprecated code, the removal, porting tests and docs, running the checks above and drafting this description). It is opened as a draft until the diff has been reviewed by a human. The review fixes in c3d2db5 were also implemented with Claude Code; the full test suite, ty and the pre-commit hooks were run afterwards, the docs build and the jax tests were not run again.

Checklist

  • I have read the contributor guide.
  • I have described any additional validation I performed (e.g., manual checks, numerical comparisons, or benchmarks) and any remaining validation gaps.
  • I have added or updated tests for changed behavior.
  • I have updated documentation for user-facing changes.
  • I have linked any issues this PR resolves using Closes #XXXX.
  • I have described any substantial AI assistance and how I checked the result.
  • I have selected the appropriate base branch and described any remaining work.

🤖 Generated with Claude Code

Remove all functionality that was deprecated in version 0.5.0 or later and
was scheduled for removal in version 0.6.0, together with the tests for it:

- deprecated arguments of minimize, maximize, first_derivative,
  second_derivative, estimate_ml, estimate_msm, slice_plot, count_free_params
  and check_constraints
- dictionary constraints, dictionary outputs of objective functions and
  dictionaries of derivative functions
- Richardson extrapolation
- deprecated attributes and dictionary access of OptimizeResult,
  MultistartInfo, History and NumdiffResult
- deprecated multistart options, old names of algorithm options, None as
  batch evaluator and OptimizeLogReader
- copies of optimagic functions in the estimagic namespace

pre_process_constraints moves to optimagic.constraints. estimate_ml raises an
error if loglike returns a dictionary with the entry "contributions", because
such a dictionary would otherwise be interpreted as a pytree of likelihood
contributions and silently lead to wrong standard errors.

Tests and documentation that still used deprecated features are ported to
the current interface.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Resolve conflicts with #727 and #741: keep the removal of read_log.py, of the
deprecated multistart options and of the deprecated type aliases in optimize.py.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/estimagic/estimate_ml.py 84.12% <100.00%> (+1.65%) ⬆️
src/estimagic/estimate_msm.py 89.30% <100.00%> (-0.26%) ⬇️
src/optimagic/batch_evaluators.py 76.53% <ø> (+1.04%) ⬆️
src/optimagic/constraints.py 92.81% <100.00%> (+0.32%) ⬆️
src/optimagic/decorators.py 93.75% <ø> (+0.64%) ⬆️
src/optimagic/deprecations.py 100.00% <100.00%> (+4.34%) ⬆️
src/optimagic/differentiation/derivatives.py 95.14% <100.00%> (-1.00%) ⬇️
...imagic/optimization/create_optimization_problem.py 89.20% <100.00%> (-0.76%) ⬇️
src/optimagic/optimization/fun_value.py 97.98% <100.00%> (+0.17%) ⬆️
src/optimagic/optimization/history.py 97.54% <100.00%> (+3.97%) ⬆️
... and 32 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

janosg and others added 2 commits November 25, 2026 08:40
Keep the deletion of richardson_extrapolation.py, which #747 had modified on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
History.time and History.runtime were never deprecated with a removal
version: since 0.5.2 they only warned that they "will be deprecated soon".
They are kept and now warn that they will be removed in version 0.7.0.

Functions marked with mark.least_squares or mark.likelihood that still return
a dictionary with the entries "contributions" or "root_contributions" were
silently read as a pytree of residuals or likelihood contributions. The check
that estimate_ml did with a wrapper now happens when the function value objects
are created. This covers minimize, maximize, slice_plot and estimate_ml, and the
error message is no longer hidden behind "Error while evaluating fun at start
params". Scalar functions that return such a dictionary get the same message.

CHANGES.md also lists the removed bounds arguments of slice_plot_3d and says
which functions had soft bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deprecated code stays isolated from the rest of the code base, so that
removing it later only means deleting it. optimagic/deprecations.py and
tests/optimagic/test_deprecations.py are kept for this purpose and now hold
the deprecation of History.time and History.runtime. The properties on
History only call deprecations.get_history_time, whose warning points to the
caller.

The contributor guide gets a section on deprecations: where deprecated code
lives, how long it keeps working, that it warns with FutureWarning, and how
to test it. Renamed public functions use warnings.deprecated from the
standard library instead of the removed deprecated decorator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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