Skip to content

Commit e9515cc

Browse files
committed
fix environment problems for windows and mac
1 parent 622fd2c commit e9515cc

9 files changed

Lines changed: 19 additions & 8 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ jobs:
3636
python=${{ matrix.python-version }}
3737
- name: run pytest
3838
shell: bash -l {0}
39+
if: runner.os == 'Linux' && matrix.python-version == '3.13'
3940
run: |
4041
micromamba activate optimagic
4142
pytest --cov-report=xml --cov=./
43+
- name: run pytest (and install pyensmallen)
44+
shell: bash -l {0}
45+
if: runner.os == 'Linux' && matrix.python-version < '3.13'
46+
run: |
47+
micromamba activate optimagic
48+
pip install pyensmallen
49+
pytest --cov-report=xml --cov=./
4250
- name: Upload coverage report.
4351
if: runner.os == 'Linux' && matrix.python-version == '3.10'
4452
uses: codecov/codecov-action@v4

.tools/envs/testenv-linux.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ dependencies:
3131
- DFO-LS>=1.5.3 # dev, tests
3232
- Py-BOBYQA # dev, tests
3333
- fides==0.7.4 # dev, tests
34-
- pyensmallen
3534
- kaleido # dev, tests
3635
- pandas-stubs # dev, tests
3736
- types-cffi # dev, tests

.tools/envs/testenv-numpy.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies:
2929
- DFO-LS>=1.5.3 # dev, tests
3030
- Py-BOBYQA # dev, tests
3131
- fides==0.7.4 # dev, tests
32-
- pyensmallen
3332
- kaleido # dev, tests
3433
- types-cffi # dev, tests
3534
- types-openpyxl # dev, tests

.tools/envs/testenv-others.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies:
2929
- DFO-LS>=1.5.3 # dev, tests
3030
- Py-BOBYQA # dev, tests
3131
- fides==0.7.4 # dev, tests
32-
- pyensmallen
3332
- kaleido # dev, tests
3433
- pandas-stubs # dev, tests
3534
- types-cffi # dev, tests

.tools/envs/testenv-pandas.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ dependencies:
2929
- DFO-LS>=1.5.3 # dev, tests
3030
- Py-BOBYQA # dev, tests
3131
- fides==0.7.4 # dev, tests
32-
- pyensmallen
3332
- kaleido # dev, tests
3433
- types-cffi # dev, tests
3534
- types-openpyxl # dev, tests

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dependencies:
4040
- DFO-LS>=1.5.3 # dev, tests
4141
- Py-BOBYQA # dev, tests
4242
- fides==0.7.4 # dev, tests
43-
- pyensmallen
4443
- kaleido # dev, tests
4544
- pre-commit>=4 # dev
4645
- -e . # dev

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dependencies = [
1616
"sqlalchemy>=1.3",
1717
"annotated-types",
1818
"typing-extensions",
19-
"pyensmallen",
2019
]
2120
dynamic = ["version"]
2221
keywords = [

src/optimagic/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
else:
9292
IS_NUMBA_INSTALLED = True
9393

94+
try:
95+
import pyensmallen # noqa: F401
96+
except ImportError:
97+
IS_PYENSMALLEN_INSTALLED = False
98+
else:
99+
IS_PYENSMALLEN_INSTALLED = True
94100

95101
# ======================================================================================
96102
# Check if pandas version is newer or equal to version 2.1.0

src/optimagic/optimizers/pyensmallen_optimizers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from dataclasses import dataclass
44

55
import numpy as np
6-
import pyensmallen as pye
76
from numpy.typing import NDArray
87

98
from optimagic import mark
9+
from optimagic.config import IS_PYENSMALLEN_INSTALLED
1010
from optimagic.optimization.algo_options import (
1111
CONVERGENCE_FTOL_REL,
1212
CONVERGENCE_GTOL_ABS,
@@ -19,6 +19,9 @@
1919
)
2020
from optimagic.typing import AggregationLevel, NonNegativeFloat, PositiveInt
2121

22+
if IS_PYENSMALLEN_INSTALLED:
23+
import pyensmallen as pye
24+
2225
LIMITED_MEMORY_MAX_HISTORY = 10
2326
"""Number of memory points to be stored (default 10)."""
2427
MIN_LINE_SEARCH_STEPS = 1e-20
@@ -35,7 +38,7 @@
3538
@mark.minimizer(
3639
name="ensmallen_lbfgs",
3740
solver_type=AggregationLevel.SCALAR,
38-
is_available=True,
41+
is_available=IS_PYENSMALLEN_INSTALLED,
3942
is_global=False,
4043
needs_jac=True,
4144
needs_hess=False,

0 commit comments

Comments
 (0)