optimagic-dev / optimagic

optimagic is a Python package for numerical optimization. It is a unified interface to optimizers from SciPy, NlOpt and other packages. optimagic's minimize function works just like SciPy's, so you don't have to adjust your code. You simply get more optimizers for free. On top you get diagnostic tools, parallel numerical derivatives and more.
https://optimagic.readthedocs.io/
MIT License
270 stars 30 forks source link

Implement filtered autocomplete for algorithm selection #534

Closed janosg closed 4 weeks ago

janosg commented 2 months ago

Short description

After this PR, algorithms can for example be selected as follows:

import optimagic as om
import numpy as np 

om.minimize(
    fun=lambda x: x @ x,
    params=np.arange(3),
    algorithm=om.algos.Bounded.scipy_lbfgsb,
)

After typing om.algos.Bounded, the autocomplete in any modern editor will only suggest algorithms that support bound constraints.

Categories that can be used to filter algorithms are:

Categories can be selected in any order. We make sure that mutually exclusive categories (e.g. Local and Global) cannot be selected at the same time.

Detailed description

The changes are described in EP-02: Static Typing

Deviations from the EP

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Files with missing lines Coverage Δ
src/optimagic/__init__.py 100.00% <100.00%> (+6.89%) :arrow_up:
src/optimagic/algorithms.py 85.58% <ø> (-14.42%) :arrow_down:
src/optimagic/config.py 70.96% <100.00%> (+0.47%) :arrow_up:
review-notebook-app[bot] commented 2 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

janosg commented 1 month ago

Tests are failing due to the release of DFO-LS 1.5.1; This is unrelated to the current changes and would affect all currently open PRs (@timmens, @mpetrosian).