Repository navigation
Conversation
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>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem do you want to solve?
Version
0.6.0is the release in which everything that was deprecated in0.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" inCHANGES.md.Removed
optimagic/deprecations.py,optimagic/logging/read_log.py(OptimizeLogReader),estimagic/utilities.py,estimagic/batch_evaluators.py, the deprecated re-exports inestimagic/__init__.pyand thedeprecateddecorator.minimize,maximize,first_derivative,second_derivative,estimate_ml,estimate_msm,slice_plot,count_free_paramsandcheck_constraints.loc/queryselection andFixedValueConstraint), dictionary outputs of objective functions and dictionaries of derivative functions.richardson_extrapolation.pyand its helpers inderivatives.py).OptimizeResult,MultistartInfo,History(exceptHistory.timeandHistory.runtime, see below) andNumdiffResult, deprecated multistart options, the translation of old algorithm option names andNoneas batch evaluator.tests/optimagic/test_deprecations.pyand other tests of deprecated behavior.Changed
pre_process_constraintsmoves tooptimagic.constraints. Its tests that are not about dictionaries move totests/optimagic/test_constraints.py.ScalarFunctionValue,LeastSquaresFunctionValueandLikelihoodFunctionValueraise anInvalidFunctionErrorfor a dictionary with the entries "contributions" or "root_contributions" (scalar functions also for "value"). Otherwise a function marked withmark.least_squaresormark.likelihoodthat still returns the old dictionary would be read as a pytree and silently give wrong results, e.g.minimizewould minimizevalue**2 + sum(root_contributions**2). The check coversminimize,maximize,slice_plotandestimate_ml(which marksloglikeas likelihood function itself) and its message is shown directly.History.timeandHistory.runtimeare kept until0.7.0. Since0.5.2they only warned that they "will be deprecated soon", without a version, so they were never scheduled for0.6.0. They now warn that they will be removed in0.7.0.Notes for review
algo_optionskeys (e.g."stopping.maxfun") are still converted to underscores. This happened inside the deprecation code but was never deprecated.generate_stepsandfinite_differencesstill support several steps per direction internally, whilederivatives.pynow always uses one. Simplifying them is left for a follow-up.check_constraints.pyandconsolidate_constraints.pyis untouched, because both files are replaced by the pending constraints refactoring.check_optimization_optionsrejectsfunandfun_kwargsinoptimize_optionsinstead of the removed names.stopping_max_criterion_evaluationsofnag_pybobyqa,convergence_relative_params_toleranceofpygmo_de) can now be set viaalgo_options. Modernize the fides and NAG wrappers and add wrapper standards with a wrap-optimizer skill #746 renames the option ofnag_pybobyqa; the one ofpygmo_destill has to be renamed in a follow-up.error_penalty, the noise and scaling arguments ofget_benchmark_problems, a list of algorithms inrun_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.pytest -m jax(84 passed) andtest_jax_derivatives.py(5 passed) pass.pixi run -e type-checking tyand all pre-commit hooks pass.pixi run -e docs build-docssucceeds and executes all notebooks.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,
tyand the pre-commit hooks were run afterwards, the docs build and the jax tests were not run again.Checklist
Closes #XXXX.🤖 Generated with Claude Code