Repository navigation
Support pandas 3, follow SPEC 0 for Python versions, and test each optimizer library separately - #749
Merged
Merged
Conversation
- Remove the pandas<3 pin and fix the two pandas 3 incompatibilities (traceback_report's dataframe output and LaTeX rendering of confidence intervals in estimation_table) plus pandas 3.1 deprecations. - Follow SPEC 0: drop Python 3.12, add Python 3.15. - Run all Python versions on Linux; macOS and Windows only the latest. - Add a tests-old-pandas environment and CI job to keep testing pandas 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove the optional optimizer libraries from the main test environments. Each library gets a pixi feature and an environment tests-<library>. - tests/conftest.py marks tests that are parametrized with an algorithm with the marker of its library. Test modules of one library set the marker with pytestmark. CI runs `pytest -m "<library> or <library>_wrappers"` in each library environment on Linux. - All test jobs save their coverage report; one job uploads them together. - Jobs that run with only one Python version use Python 3.14, the second newest, because the newest often has problems. - Fix test_bayesian_optimizer.py, which failed without bayesian-optimization, and give nevergrad_de and nevergrad_meta enough evaluations in test_many_algorithms.py; nevergrad never ran in those tests before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Draft
6 of 7 tasks
…das 3. - petsc4py 3.26 removed TAO.setInitial; use TAO.setSolution, which exists in all supported versions (>= 3.18). - The bootstrap tutorial replaced values of a categorical column, which pandas 3 rejects. Convert the column to integers instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Notebooks changed:
Review visual diffs and comment on any notebook cell. All comments sync back to this PR. Powered by ReviewNB |
The job names will be required status checks on main. Without the version, updating the Python version of these jobs does not require a ruleset change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd speed up CI. - Tests with a library marker are skipped if the library is missing; `pytest --library <lib>` runs one library's tests and fails on unavailable algorithms or skipped tests. A guard test rejects `skipif` on library availability flags. - Run the test tasks with pytest-xdist and fix slow tests (history collection with nevergrad, gfo internal) and pygad ignoring `stopping_maxiter`. - Fix `nevergrad_bo` never being available and the nevergrad tests that read empty optimizer lists; test nevergrad_bo with bayes-optim and cap numpy below 2.4 in the nevergrad environment until nevergrad releases its fix. - Follow SPEC 0 for minimum versions (numpy 2.2, scipy 1.15, pandas 2.3, plotly 6.0) and drop the old-plotly job. - Solve the main test environments on their own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CMA-ES reaches 5e-3 on Linux and 1e-4 on macOS with the same seed. The test never ran in CI before, because the old nevergrad job only ran test_nevergrad.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ping_maxtime stop nevergrad_cmaes. nevergrad restarts CMA-ES whenever one of its stopping criteria is met and only recommends the best point of the last restart, so nevergrad_cmaes could return a much worse point than it had evaluated. stopping_maxtime was passed to CMA-ES as timeout, which triggered such restarts instead of ending the optimization. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
janosg
commented
Nov 24, 2026
janosg
marked this pull request as ready for review
November 24, 2026 08:20
Member
Author
|
Probably the runtime of CI can be further reduced by splitting or merging jobs but I want to wait with that until more optimizer wrappers have an extensive test suite as proposed in #746 |
janosg
added a commit
that referenced
this pull request
Nov 24, 2026
The wrapper tests carry the marker of their library instead of a *_wrappers marker and no longer need to be selected with -m. They run wherever the library is installed and in the CI job of the library for every pull request, which replaces the dedicated wrapper test job. Leftover skipif decorators and importorskip calls are replaced by the library markers. The monthly wrapper-tests workflow runs the tests of each wrapped library in its own environment with --library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without this, a failing test in a library job also dropped that job's coverage report, so codecov reported all code that only this job tests as uncovered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
janosg
added a commit
that referenced
this pull request
Nov 24, 2026
The wrapper tests carry the marker of their library instead of a *_wrappers marker and no longer need to be selected with -m. They run wherever the library is installed and in the CI job of the library for every pull request, which replaces the dedicated wrapper test job. Leftover skipif decorators and importorskip calls are replaced by the library markers. The monthly wrapper-tests workflow runs the tests of each wrapped library in its own environment with --library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
timmens
approved these changes
Nov 24, 2026
timmens
left a comment
Member
There was a problem hiding this comment.
Looks very very good IMO! No comments from me.
janosg
added a commit
that referenced
this pull request
Nov 25, 2026
Keep the pandas 3 fix of traceback_report from #749, which builds the DataFrame without stack(), on top of the BenchmarkResult objects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
janosg
added a commit
that referenced
this pull request
Nov 25, 2026
… of main - tests/test_optimizer_library_markers.py (#749) read the source files with the platform encoding, which fails on Windows for the non-ASCII characters in the BHHH modules. Read them as UTF-8. - The LineSearch docs in algorithms.md and numdiff_background.md both cite Dennis1996, which sphinxcontrib-bibtex reports as a duplicate citation; since #741 the docs build fails on warnings. Prefix the keys of the local bibliography of numdiff_background.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
pandas<3pin and fix what breaks with pandas 3 / 3.1:traceback_report(return_type="dataframe"):stack()no longer drops NaN in pandas 3, so the report contained rows for algorithm/problem pairs that did not fail. The DataFrame is now built directly from the failed runs.estimation_tableLaTeX rendering with confidence intervals: assigning via a partial MultiIndex key fails in pandas 3; use a boolean row mask instead.inplace=Truecalls (deprecated in pandas 3.1) andDataFrame.from_dict(<DataFrame>).tests-old-pandasjob (pandas<3) keeps pandas 2.3 tested; SPEC 0 supports it until June 2027. Thetests-old-plotlyjob is removed, because all plotly 5 releases are more than two years old.-n auto).pygadignoredstopping_maxiter; it now runs the smaller ofnum_generationsandstopping_maxitergenerations.nevergrad_bowas never available:config.pycheckedfind_spec("bayes-optim"), which needs the module namebayes_optim.One environment and CI job per optimizer library
tests-<library>: bayesopt, fides, gfo, iminuit, ipopt, nag, nevergrad, nlopt, pygad, pygmo, pyswarms, tao, tranquilo.nlopt) is the only way a test declares that it needs the library:tests/conftest.pyadds the marker to every test that is parametrized with an algorithm of the library, e.g. the tests intest_many_algorithms.py. Test modules of one library set it withpytestmark.skipif;tests/test_optimizer_library_markers.pyfails if a test uses an availability flag such asIS_NLOPT_INSTALLEDfor anything but guarding imports.pytest --library nloptruns only the tests of nlopt. It fails if an nlopt algorithm is not available or if a selected test is skipped, so that a broken environment or an empty parametrization cannot hide tests. CI runs it on Linux with Python 3.14; locally:pixi run -e tests-nlopt tests --library nlopt.tests/test_optimizer_library_markers.pyalso fails if an optimizer module has no marker, environment or CI job.default,docsandtype-checkingstill combine all libraries that can be installed together (all except nevergrad and the Linux-only tao), becausetyand the docs need them. The main test environments are no longer in a solve group with them, so the libraries cannot restrict the versions of optimagic's own dependencies.Tests that the old setup never ran, fixed here:
test_bayesian_optimizer.pyfailed to collect without bayesian-optimization.test_infinite_and_incomplete_bounds.pyskipped itself without nevergrad, but the old nevergrad job only rantest_nevergrad.py.nevergrad_deandnevergrad_metadid not reach the required precision intest_many_algorithms.pywith the default budget of 1000 evaluations; the test now gives them 20,000.nevergrad_bo(see above). The nevergrad environment now installs bayes-optim, withpytorch-cpufrom conda-forge andpydoe<0.4, because bayes-optim imports the modulepyDOE, which pydoe 1.0 renamed.test_nevergrad.pyread the optimizer names ofnevergrad_metaandnevergrad_ngoptwithget_argsfrom string annotations, which returns(). The tests over all 37 Meta and 52 NGOpt optimizers, and the check that they exist in nevergrad, therefore never ran. They run now; NoisyBandit does not reach the required precision and is marked as an expected failure.test_with_nonlinear_constraints.pyskipped slow cases at runtime; they are now left out of the parametrization, so that--librarydoes not count them as skipped.Tests that were slow:
test_history_collection_with_parallelizationsetstopping_maxiter=3, which most nevergrad algorithms do not have, so each of them ran 1,000 evaluations (about 14 seconds). The test now setsstopping_maxfunorstopping_maxiter, whichever the algorithm has. With the pygad fix, pygad stops after 3 generations instead of 50 (66 seconds before).test_gfo_internalran up to 1,000,000 iterations (about 50 seconds); 2,000 give the same result.Dependency notes
petsc4pycannot be installed together withcyipopt/pygmo(int64 vs. int32 variant oflibscotchon conda-forge). With a separate tao environment this no longer matters.pytorch-cpufrom the base dependencies: nothing there uses it (it was added in Fix recent issues with CI #656 to keep pip from installing CUDA torch). The nevergrad environment needs it again for bayes-optim.h5py(for fides),scikit-learn(for bayesian-optimization) andorjson(for kaleido) come from conda-forge, because PyPI has no Python 3.15 wheels for them yet.gradient-free-optimizers(≤1.13.0, also on its main branch) declarespandas<3. A pixidependency-overridesentry in the gfo environment lets CI test it against pandas 3, and its tests pass. Users who install it with pip are still held at pandas 2 until upstream drops the cap.float()on an array with one element in its metamodel, which numpy ≥ 2.4 rejects. Meta and NGOpt optimizers that use the metamodel (e.g. NgIoh4, Wiz, CSEC) crash and leave a thread behind that keeps Python from exiting. This is fixed on nevergrad's main branch (NGOpt is incompatible with numpy 2.4.0 facebookresearch/nevergrad#1707) but not released, so the nevergrad environment usesnumpy<2.4until the next release. Users with numpy ≥ 2.4 hit this bug with these optimizers.Testing
Locally on macOS with Python 3.14: the main environment, all library environments with
--libraryexcept tao (Linux-only), thedefaultenvironment with all compatible libraries,tests-old-pandas,tyandprekpass. Earlier runs also passed on Python 3.15 with pandas 3.1.1 and on Python 3.13 with pandas 2.3.3. The tao job and the combined coverage upload are only checked by CI.🤖 Generated with Claude Code
Closes #748