Skip to content

Commit f28d4a3

Browse files
authored
Merge branch 'main' into boilerplate
2 parents d58d54b + 06a4bb2 commit f28d4a3

159 files changed

Lines changed: 18950 additions & 1619 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODE_OF_CONDUCT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Code of Conduct
2+
3+
- [NumFOCUS Code of Conduct](https://numfocus.org/code-of-conduct)

.github/workflows/main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,54 @@ jobs:
127127
run: |
128128
micromamba activate optimagic
129129
pytest -m "not slow and not jax"
130+
run-tests-with-old-plotly:
131+
name: Run tests for ubuntu-latest on 3.10 with plotly < 6 and kaleido < 0.3
132+
runs-on: ubuntu-latest
133+
strategy:
134+
fail-fast: false
135+
steps:
136+
- uses: actions/checkout@v4
137+
- name: create build environment
138+
uses: mamba-org/setup-micromamba@v1
139+
with:
140+
environment-file: ./.tools/envs/testenv-plotly.yml
141+
cache-environment: true
142+
create-args: |
143+
python=3.10
144+
- name: run pytest
145+
shell: bash -l {0}
146+
run: |
147+
micromamba activate optimagic
148+
pytest -m "not slow and not jax"
149+
run-tests-nevergrad:
150+
# This job is for running test related to nevergrad with pinned version of
151+
# bayesian_optimization == 1.4.0
152+
name: Run tests for ubuntu-latest on ${{ matrix.python-version }} bayes_opt==1.4.0
153+
runs-on: ${{ matrix.os }}
154+
strategy:
155+
fail-fast: false
156+
matrix:
157+
os:
158+
- ubuntu-latest
159+
python-version:
160+
- '3.10'
161+
- '3.11'
162+
- '3.12'
163+
- '3.13'
164+
steps:
165+
- uses: actions/checkout@v4
166+
- name: create build environment
167+
uses: mamba-org/setup-micromamba@v1
168+
with:
169+
environment-file: ./.tools/envs/testenv-nevergrad.yml
170+
cache-environment: true
171+
create-args: |
172+
python=${{ matrix.python-version }}
173+
- name: run pytest
174+
shell: bash -l {0}
175+
run: |
176+
micromamba activate optimagic
177+
pytest tests/optimagic/optimizers/test_nevergrad.py
130178
code-in-docs:
131179
name: Run code snippets in documentation
132180
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# AI
2+
CLAUDE.md
3+
14
# Byte-compiled / optimized / DLL files
25
*.py[cod]
36
*$py.class

.pre-commit-config.yaml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: check-useless-excludes
77
# - id: identity # Prints all files passed to pre-commits. Debugging.
88
- repo: https://github.com/lyz-code/yamlfix
9-
rev: 1.17.0
9+
rev: 1.19.1
1010
hooks:
1111
- id: yamlfix
1212
exclude: tests/optimagic/optimizers/_pounders/fixtures
@@ -18,20 +18,29 @@ repos:
1818
language: python
1919
always_run: true
2020
require_serial: true
21+
- repo: local
22+
hooks:
23+
- id: check-mypy-versions
24+
name: verify that pre-commits and dev env use the same mypy version
25+
entry: python .tools/check_mypy_versions.py
26+
language: python
27+
always_run: true
28+
require_serial: true
29+
additional_dependencies:
30+
- pyyaml
2131
- repo: local
2232
hooks:
2333
- id: update-algo-selection-code
2434
name: update algo selection code
25-
entry: bash .tools/create_and_format_algo_selection_code.sh
35+
entry: python .tools/update_algo_selection_hook.py
2636
language: python
27-
files: (src/optimagic/optimizers/.|src/optimagic/algorithms.py|.tools/.)
28-
always_run: false
37+
files: ^(src/optimagic/optimizers/|src/optimagic/algorithms\.py|\.tools/)
2938
require_serial: true
3039
additional_dependencies:
3140
- hatchling
3241
- ruff
3342
- repo: https://github.com/pre-commit/pre-commit-hooks
34-
rev: v5.0.0
43+
rev: v6.0.0
3544
hooks:
3645
- id: check-added-large-files
3746
args:
@@ -63,12 +72,12 @@ repos:
6372
exclude: docs/
6473
- id: check-ast
6574
- repo: https://github.com/adrienverge/yamllint.git
66-
rev: v1.35.1
75+
rev: v1.38.0
6776
hooks:
6877
- id: yamllint
6978
exclude: tests/optimagic/optimizers/_pounders/fixtures
7079
- repo: https://github.com/PyCQA/docformatter
71-
rev: eb1df34
80+
rev: v1.7.7
7281
hooks:
7382
- id: docformatter
7483
args:
@@ -80,7 +89,7 @@ repos:
8089
- --blank
8190
exclude: src/optimagic/optimization/algo_options.py
8291
- repo: https://github.com/astral-sh/ruff-pre-commit
83-
rev: v0.7.2
92+
rev: v0.14.14
8493
hooks:
8594
# Run the linter.
8695
- id: ruff
@@ -97,7 +106,7 @@ repos:
97106
- pyi
98107
- jupyter
99108
- repo: https://github.com/executablebooks/mdformat
100-
rev: 0.7.18
109+
rev: 1.0.0
101110
hooks:
102111
- id: mdformat
103112
additional_dependencies:
@@ -109,7 +118,7 @@ repos:
109118
- '88'
110119
files: (README\.md)
111120
- repo: https://github.com/executablebooks/mdformat
112-
rev: 0.7.18
121+
rev: 1.0.0
113122
hooks:
114123
- id: mdformat
115124
additional_dependencies:
@@ -121,7 +130,7 @@ repos:
121130
files: (docs/.)
122131
exclude: docs/source/how_to/how_to_specify_algorithm_and_algo_options.md
123132
- repo: https://github.com/kynan/nbstripout
124-
rev: 0.8.0
133+
rev: 0.9.0
125134
hooks:
126135
- id: nbstripout
127136
exclude: |
@@ -132,21 +141,25 @@ repos:
132141
args:
133142
- --drop-empty-cells
134143
- repo: https://github.com/pre-commit/mirrors-mypy
135-
rev: v1.13.0
144+
rev: v1.19.1
136145
hooks:
137146
- id: mypy
138147
files: src|tests
139148
additional_dependencies:
140-
- numpy
149+
- numpy >= 2
141150
- packaging
142151
- pandas-stubs
143152
- sqlalchemy-stubs
144153
- types-cffi
145154
- types-openpyxl
146155
- types-jinja2
147-
args:
148-
- --config=pyproject.toml
156+
- bokeh
149157
ci:
150158
autoupdate_schedule: monthly
151159
skip:
152160
- update-algo-selection-code
161+
# Skip mypy stubtest on pre-commit.ci due to maximum size limitations. This is
162+
# unlikely to get better in the future as dependencies keep growing. Local runs
163+
# of pre-commit would still execute stubtest. For CI, we have a separate GitHub
164+
# Action that runs stubtest.
165+
- mypy

.tools/check_mypy_versions.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import re
2+
import sys
3+
from pathlib import Path
4+
5+
import yaml
6+
7+
8+
def _get_mypy_version_from_precommit_config() -> str:
9+
config = yaml.safe_load(Path(".pre-commit-config.yaml").read_text())
10+
mypy_config = [
11+
hook
12+
for hook in config["repos"]
13+
if hook["repo"] == "https://github.com/pre-commit/mirrors-mypy"
14+
][0]
15+
match = re.search(r"v([\d.]+)", mypy_config["rev"]) # Remove "v" prefix
16+
if match:
17+
return match.group(1)
18+
raise ValueError("Mypy version not found in pre-commit config.")
19+
20+
21+
def _get_mypy_version_from_conda_environment() -> str:
22+
config = yaml.safe_load(Path("environment.yml").read_text())
23+
mypy_line = [dep for dep in config["dependencies"] if "mypy" in dep][0]
24+
match = re.search(r"mypy=([\d.]+)", mypy_line)
25+
if match:
26+
return match.group(1)
27+
raise ValueError("Mypy version not found in conda environment.")
28+
29+
30+
def main() -> None:
31+
v_precommit = _get_mypy_version_from_precommit_config()
32+
v_conda = _get_mypy_version_from_conda_environment()
33+
if v_precommit != v_conda:
34+
print(
35+
f"Error: Mypy versions do not match:\n"
36+
f" Pre-commit config: {v_precommit}\n"
37+
f" Conda environment: {v_conda}\n"
38+
)
39+
sys.exit(1)
40+
sys.exit(0)
41+
42+
43+
if __name__ == "__main__":
44+
main()

.tools/create_and_format_algo_selection_code.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

.tools/envs/testenv-linux.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ channels:
44
- conda-forge
55
- nodefaults
66
dependencies:
7-
- petsc4py
7+
- petsc4py<=3.23.4
88
- jax
99
- cyipopt>=1.4.0 # dev, tests
10-
- pygmo>=2.19.0 # dev, tests
10+
- pygmo>=2.19.0 # dev, tests, docs
1111
- nlopt # dev, tests, docs
1212
- pip # dev, tests, docs
1313
- pytest # dev, tests
@@ -18,20 +18,30 @@ dependencies:
1818
- joblib # run, tests
1919
- numpy >= 2 # run, tests
2020
- pandas # run, tests
21-
- plotly # run, tests
21+
- plotly>=6.2 # run, tests
22+
- matplotlib # tests
23+
- bokeh # tests
24+
- altair # tests
2225
- pybaum>=0.1.2 # run, tests
2326
- scipy>=1.2.1 # run, tests
2427
- sqlalchemy # run, tests
2528
- seaborn # dev, tests
26-
- mypy=1.13 # dev, tests
29+
- mypy=1.19.1 # dev, tests
2730
- pyyaml # dev, tests
2831
- jinja2 # dev, tests
2932
- annotated-types # dev, tests
33+
- iminuit # dev, tests
34+
- cma # dev, tests
35+
- pygad # dev, tests
36+
- pytorch-cpu # dev, tests
3037
- pip: # dev, tests, docs
38+
- bayesian-optimization>=2.0.4 # dev, tests
3139
- DFO-LS>=1.5.3 # dev, tests
3240
- Py-BOBYQA # dev, tests
3341
- fides==0.7.4 # dev, tests
34-
- kaleido # dev, tests
42+
- kaleido>=1.0 # dev, tests
43+
- gradient_free_optimizers # dev, tests
44+
- pyswarms # dev, tests
3545
- pandas-stubs # dev, tests
3646
- types-cffi # dev, tests
3747
- types-openpyxl # dev, tests

.tools/envs/testenv-nevergrad.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: optimagic
3+
channels:
4+
- conda-forge
5+
- nodefaults
6+
dependencies:
7+
- cyipopt>=1.4.0 # dev, tests
8+
- pygmo>=2.19.0 # dev, tests, docs
9+
- nlopt # dev, tests, docs
10+
- pip # dev, tests, docs
11+
- pytest # dev, tests
12+
- pytest-cov # tests
13+
- pytest-xdist # dev, tests
14+
- statsmodels # dev, tests
15+
- cloudpickle # run, tests
16+
- joblib # run, tests
17+
- numpy >= 2 # run, tests
18+
- pandas # run, tests
19+
- plotly>=6.2 # run, tests
20+
- matplotlib # tests
21+
- bokeh # tests
22+
- altair # tests
23+
- pybaum>=0.1.2 # run, tests
24+
- scipy>=1.2.1 # run, tests
25+
- sqlalchemy # run, tests
26+
- seaborn # dev, tests
27+
- mypy=1.19.1 # dev, tests
28+
- pyyaml # dev, tests
29+
- jinja2 # dev, tests
30+
- annotated-types # dev, tests
31+
- iminuit # dev, tests
32+
- cma # dev, tests
33+
- pygad # dev, tests
34+
- pytorch-cpu # dev, tests
35+
- pip: # dev, tests, docs
36+
- DFO-LS>=1.5.3 # dev, tests
37+
- Py-BOBYQA # dev, tests
38+
- fides==0.7.4 # dev, tests
39+
- kaleido>=1.0 # dev, tests
40+
- gradient_free_optimizers # dev, tests
41+
- pyswarms # dev, tests
42+
- pandas-stubs # dev, tests
43+
- types-cffi # dev, tests
44+
- types-openpyxl # dev, tests
45+
- types-jinja2 # dev, tests
46+
- sqlalchemy-stubs # dev, tests
47+
- sphinxcontrib-mermaid # dev, tests, docs
48+
- bayesian_optimization==1.4.0
49+
- nevergrad
50+
- -e ../../

.tools/envs/testenv-numpy.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
- pandas>=2
88
- numpy<2
99
- cyipopt>=1.4.0 # dev, tests
10-
- pygmo>=2.19.0 # dev, tests
10+
- pygmo>=2.19.0 # dev, tests, docs
1111
- nlopt # dev, tests, docs
1212
- pip # dev, tests, docs
1313
- pytest # dev, tests
@@ -16,20 +16,30 @@ dependencies:
1616
- statsmodels # dev, tests
1717
- cloudpickle # run, tests
1818
- joblib # run, tests
19-
- plotly # run, tests
19+
- plotly>=6.2 # run, tests
20+
- matplotlib # tests
21+
- bokeh # tests
22+
- altair # tests
2023
- pybaum>=0.1.2 # run, tests
2124
- scipy>=1.2.1 # run, tests
2225
- sqlalchemy # run, tests
2326
- seaborn # dev, tests
24-
- mypy=1.13 # dev, tests
27+
- mypy=1.19.1 # dev, tests
2528
- pyyaml # dev, tests
2629
- jinja2 # dev, tests
2730
- annotated-types # dev, tests
31+
- iminuit # dev, tests
32+
- cma # dev, tests
33+
- pygad # dev, tests
34+
- pytorch-cpu # dev, tests
2835
- pip: # dev, tests, docs
36+
- bayesian-optimization>=2.0.4 # dev, tests
2937
- DFO-LS>=1.5.3 # dev, tests
3038
- Py-BOBYQA # dev, tests
3139
- fides==0.7.4 # dev, tests
32-
- kaleido # dev, tests
40+
- kaleido>=1.0 # dev, tests
41+
- gradient_free_optimizers # dev, tests
42+
- pyswarms # dev, tests
3343
- types-cffi # dev, tests
3444
- types-openpyxl # dev, tests
3545
- types-jinja2 # dev, tests

0 commit comments

Comments
 (0)