Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tranquilo an optional dependency #464

Merged
merged 6 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envs/testenv-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ dependencies:
- click # run, tests
- cloudpickle # run, tests
- joblib # run, tests
- numba # run, tests
- numpy>=1.17.0 # run, tests
- pandas # run, tests
- plotly # run, tests
- pybaum >= 0.1.2 # run, tests
- scipy>=1.2.1 # run, tests
- sqlalchemy # run, tests
- tranquilo>=0.0.4 # dev, tests
- pip: # dev, tests, docs
- DFO-LS # dev, tests
- Py-BOBYQA # dev, tests
Expand Down
2 changes: 1 addition & 1 deletion .envs/testenv-others.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ dependencies:
- click # run, tests
- cloudpickle # run, tests
- joblib # run, tests
- numba # run, tests
- numpy>=1.17.0 # run, tests
- pandas # run, tests
- plotly # run, tests
- pybaum >= 0.1.2 # run, tests
- scipy>=1.2.1 # run, tests
- sqlalchemy # run, tests
- tranquilo>=0.0.4 # dev, tests
- pip: # dev, tests, docs
- DFO-LS # dev, tests
- Py-BOBYQA # dev, tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
os:
- ubuntu-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- uses: actions/checkout@v3
- name: create build environment
Expand Down Expand Up @@ -54,9 +54,9 @@ jobs:
- macos-latest
- windows-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- uses: actions/checkout@v3
- name: create build environment
Expand Down
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ This is a record of all past estimagic releases and what went into them in rever
chronological order. We follow [semantic versioning](https://semver.org/) and all
releases are available on [Anaconda.org](https://anaconda.org/OpenSourceEconomics/estimagic).

Following the [scientific python guidelines](https://scientific-python.org/specs/spec-0000/)
we drop the official support for Python 3.8.


## 0.4.6

This release drastically improves the optimizer benchmarking capabilities, especially
with noisy functions and parallel optimizers. It makes tranquilo and numba optional
dependencies and is the first version of estimagic to be compatible with Python
3.11.


- {gh}`464` Makes tranquilo and numba optional dependencies ({ghuser}`janosg`)
- {gh}`461` Updates docstrings for procss_benchmark_results ({ghuser}`segsell`)
- {gh}`460` Fixes several bugs in the processing of benchmark results with noisy
functions ({ghuser}`janosg`)
- {gh}`459` Prepares benchmarking functionality for parallel optimizers
({ghuser}`mpetrosian` and {ghuser}`janosg`)
- {gh}`457` Removes some unused files ({ghuser}`segsell`)
- {gh}`455` Improves a local pre-commit hook ({ghuser}`ChristianZimpelmann`)


## 0.4.5

Expand Down
1 change: 0 additions & 1 deletion docs/rtd_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies:
- ipython_genutils
- myst-nb
- pydata-sphinx-theme<=0.12.0
- numba
- pybaum
- matplotlib
- seaborn
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"petsc4py",
"statsmodels",
"numba",
"tranquilo",
]

extlinks = {
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- click # run, tests
- cloudpickle # run, tests
- joblib # run, tests
- numba # run, tests
- numpy>=1.17.0 # run, tests
- pandas # run, tests
- plotly # run, tests
Expand All @@ -35,6 +34,7 @@ dependencies:
- sphinx-copybutton # docs
- sphinx-panels # docs
- sphinxcontrib-bibtex # docs
- tranquilo>=0.0.4 # dev, tests
- pip: # dev, tests, docs
- DFO-LS # dev, tests
- Py-BOBYQA # dev, tests
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ filterwarnings = [
"ignore:Widget._widget_types is deprecated",
"ignore:Widget.widget_types is deprecated",
"ignore:Widget.widgets is deprecated",
"ignore:Parallelization together with",
janosg marked this conversation as resolved.
Show resolved Hide resolved
]
addopts = ["--doctest-modules"]
markers = [
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ install_requires =
click
cloudpickle
joblib
numba
numpy>=1.17.0
pandas
plotly
Expand Down
46 changes: 46 additions & 0 deletions src/estimagic/algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import inspect

from estimagic.optimization import (
bhhh,
cyipopt_optimizers,
fides_optimizers,
nag_optimizers,
neldermead,
nlopt_optimizers,
pounders,
pygmo_optimizers,
scipy_optimizers,
simopt_optimizers,
tao_optimizers,
tranquilo,
)

MODULES = [
cyipopt_optimizers,
fides_optimizers,
nag_optimizers,
nlopt_optimizers,
pygmo_optimizers,
scipy_optimizers,
simopt_optimizers,
tao_optimizers,
bhhh,
neldermead,
pounders,
tranquilo,
janosg marked this conversation as resolved.
Show resolved Hide resolved
]

ALL_ALGORITHMS = {}
AVAILABLE_ALGORITHMS = {}
for module in MODULES:
func_dict = dict(inspect.getmembers(module, inspect.isfunction))
for name, func in func_dict.items():
if hasattr(func, "_algorithm_info"):
ALL_ALGORITHMS[name] = func
if func._algorithm_info.is_available:
AVAILABLE_ALGORITHMS[name] = func


GLOBAL_ALGORITHMS = [
name for name, func in ALL_ALGORITHMS.items() if func._algorithm_info.is_global
]
10 changes: 9 additions & 1 deletion src/estimagic/benchmarking/cartis_roberts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
"""
from functools import partial

from numba import njit
import numpy as np
from estimagic.config import IS_NUMBA_INSTALLED

if IS_NUMBA_INSTALLED:
from numba import njit
else:

def njit(func):
return func


from estimagic.benchmarking.more_wild import (
brown_almost_linear,
Expand Down
2 changes: 1 addition & 1 deletion src/estimagic/benchmarking/run_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from estimagic import batch_evaluators
from estimagic.optimization import AVAILABLE_ALGORITHMS
from estimagic.algorithms import AVAILABLE_ALGORITHMS
from estimagic.optimization.optimize import minimize
from pybaum import tree_just_flatten
from estimagic.parameters.tree_registry import get_registry
Expand Down
16 changes: 16 additions & 0 deletions src/estimagic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@
IS_SIMOPT_INSTALLED = True


try:
import tranquilo # noqa: F401
except ImportError:
IS_TRANQUILO_INSTALLED = False
else:
IS_TRANQUILO_INSTALLED = True


try:
import numba # noqa: F401
except ImportError:
IS_NUMBA_INSTALLED = False
else:
IS_NUMBA_INSTALLED = True


# =================================================================================
# Dashboard Defaults
# =================================================================================
Expand Down
46 changes: 0 additions & 46 deletions src/estimagic/optimization/__init__.py
Original file line number Diff line number Diff line change
@@ -1,46 +0,0 @@
import inspect

from estimagic.optimization import (
bhhh,
cyipopt_optimizers,
fides_optimizers,
nag_optimizers,
neldermead,
nlopt_optimizers,
pounders,
pygmo_optimizers,
scipy_optimizers,
simopt_optimizers,
tao_optimizers,
)
from estimagic.optimization.tranquilo import tranquilo

MODULES = [
cyipopt_optimizers,
fides_optimizers,
nag_optimizers,
nlopt_optimizers,
pygmo_optimizers,
scipy_optimizers,
simopt_optimizers,
tao_optimizers,
bhhh,
neldermead,
pounders,
tranquilo,
]

ALL_ALGORITHMS = {}
AVAILABLE_ALGORITHMS = {}
for module in MODULES:
func_dict = dict(inspect.getmembers(module, inspect.isfunction))
for name, func in func_dict.items():
if hasattr(func, "_algorithm_info"):
ALL_ALGORITHMS[name] = func
if func._algorithm_info.is_available:
AVAILABLE_ALGORITHMS[name] = func


GLOBAL_ALGORITHMS = [
name for name, func in ALL_ALGORITHMS.items() if func._algorithm_info.is_global
]
2 changes: 1 addition & 1 deletion src/estimagic/optimization/get_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
list_of_dicts_to_dict_of_lists,
)
from estimagic.logging.write_to_database import update_row
from estimagic.optimization import ALL_ALGORITHMS
from estimagic.algorithms import ALL_ALGORITHMS
from estimagic.utilities import propose_alternatives


Expand Down
Loading