Skip to content

Commit b8ec2cc

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents 8cd4b02 + 567464d commit b8ec2cc

21 files changed

+1282
-240
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ repos:
137137
- id: mypy
138138
files: src|tests
139139
additional_dependencies:
140-
- numpy
140+
- numpy >= 2
141141
- packaging
142142
- pandas-stubs
143143
- sqlalchemy-stubs

.tools/envs/testenv-linux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
- joblib # run, tests
1919
- numpy >= 2 # run, tests
2020
- pandas # run, tests
21-
- plotly # run, tests
21+
- plotly<6.0.0 # run, tests
2222
- pybaum>=0.1.2 # run, tests
2323
- scipy>=1.2.1 # run, tests
2424
- sqlalchemy # run, tests

.tools/envs/testenv-numpy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- statsmodels # dev, tests
1717
- cloudpickle # run, tests
1818
- joblib # run, tests
19-
- plotly # run, tests
19+
- plotly<6.0.0 # run, tests
2020
- pybaum>=0.1.2 # run, tests
2121
- scipy>=1.2.1 # run, tests
2222
- sqlalchemy # run, tests

.tools/envs/testenv-others.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- joblib # run, tests
1717
- numpy >= 2 # run, tests
1818
- pandas # run, tests
19-
- plotly # run, tests
19+
- plotly<6.0.0 # run, tests
2020
- pybaum>=0.1.2 # run, tests
2121
- scipy>=1.2.1 # run, tests
2222
- sqlalchemy # run, tests

.tools/envs/testenv-pandas.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- statsmodels # dev, tests
1717
- cloudpickle # run, tests
1818
- joblib # run, tests
19-
- plotly # run, tests
19+
- plotly<6.0.0 # run, tests
2020
- pybaum>=0.1.2 # run, tests
2121
- scipy>=1.2.1 # run, tests
2222
- sqlalchemy # run, tests

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- joblib # run, tests
2121
- numpy >= 2 # run, tests
2222
- pandas # run, tests
23-
- plotly # run, tests
23+
- plotly<6.0.0 # run, tests
2424
- pybaum>=0.1.2 # run, tests
2525
- scipy>=1.2.1 # run, tests
2626
- sqlalchemy # run, tests

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies = [
1010
"joblib",
1111
"numpy",
1212
"pandas",
13-
"plotly",
13+
"plotly<6.0.0",
1414
"pybaum>=0.1.2",
1515
"scipy>=1.2.1",
1616
"sqlalchemy>=1.3",

src/optimagic/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from optimagic import constraints, mark, utilities
3+
from optimagic import constraints, mark, timing, utilities
44
from optimagic.algorithms import algos
55
from optimagic.benchmarking.benchmark_reports import (
66
convergence_report,
@@ -102,4 +102,5 @@
102102
"History",
103103
"__version__",
104104
"algos",
105+
"timing",
105106
]

src/optimagic/benchmarking/run_benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def _process_one_result(optimize_result, problem):
209209
criterion_history = history.fun
210210
criterion_history = np.clip(criterion_history, _solution_crit, np.inf)
211211
batches_history = history.batches
212-
time_history = history.time
212+
time_history = history.start_time
213213

214214
return {
215215
"params_history": params_history_flat,

src/optimagic/optimization/convergence_report.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import numpy as np
2+
from numpy.typing import NDArray
23

3-
from optimagic.optimization.history_tools import get_history_arrays
4+
from optimagic.optimization.history import History
45

56

6-
def get_convergence_report(history, direction):
7-
history_arrs = get_history_arrays(
8-
history=history,
9-
direction=direction,
10-
)
7+
def get_convergence_report(history: History) -> dict[str, dict[str, float]] | None:
8+
is_accepted = history.is_accepted
119

12-
critvals = history_arrs.fun[history_arrs.is_accepted]
13-
params = history_arrs.params[history_arrs.is_accepted]
10+
critvals = np.array(history.fun, dtype=np.float64)[is_accepted]
11+
params = np.array(history.flat_params, dtype=np.float64)[is_accepted]
1412

1513
if len(critvals) < 2:
1614
out = None
@@ -35,7 +33,7 @@ def get_convergence_report(history, direction):
3533
return out
3634

3735

38-
def _get_max_f_changes(critvals):
36+
def _get_max_f_changes(critvals: NDArray[np.float64]) -> tuple[float, float]:
3937
best_val = critvals[-1]
4038
worst_val = critvals[0]
4139

@@ -47,7 +45,7 @@ def _get_max_f_changes(critvals):
4745
return max_change_rel, max_change_abs
4846

4947

50-
def _get_max_x_changes(params):
48+
def _get_max_x_changes(params: NDArray[np.float64]) -> tuple[float, float]:
5149
best_x = params[-1]
5250
diffs = params - best_x
5351
denom = np.clip(np.abs(best_x), 0.1, np.inf)

0 commit comments

Comments
 (0)