Skip to content

Commit

Permalink
TST: minimize_ipopt: don't run new tests if SciPy isn't available
Browse files Browse the repository at this point in the history
  • Loading branch information
mdhaber committed May 29, 2023
1 parent 1308dd4 commit 16ccf04
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cyipopt/tests/unit/test_scipy_ipopt_from_scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
Unit tests written for scipy.optimize.minimize method='SLSQP';
adapted for minimize_ipopt
"""
import sys
import pytest
from numpy.testing import (assert_, assert_allclose)
import numpy as np

from scipy.optimize import Bounds, NonlinearConstraint
try:
from scipy.optimize import Bounds
except ImportError:
pass

from cyipopt import minimize_ipopt as minimize


Expand All @@ -23,6 +29,8 @@ def __call__(self, x):
self.ncalls += 1


@pytest.mark.skipif("scipy" not in sys.modules,
reason="Test only valid if Scipy available.")
class TestSLSQP:
"""
Test SLSQP algorithm using Example 14.4 from Numerical Methods for
Expand Down Expand Up @@ -288,7 +296,8 @@ def test_invalid_bounds(self):
]
for bounds in bounds_list:
res = minimize(self.fun, [-1.0, 1.0], bounds=bounds, method=None)
assert res.status == -11 # invalid problem definition
# "invalid problem definition" or "problem may be infeasible"
assert res.status == -11 or res.status == 2

def test_bounds_clipping(self):
#
Expand Down

0 comments on commit 16ccf04

Please sign in to comment.