Skip to content

Commit 2c71c69

Browse files
committed
formatting and comment for posterity
1 parent 63a6c53 commit 2c71c69

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

tests/test_hs071.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,14 @@ def test_optimization(self, optName):
222222
lambda_con1 = float(lines[con1_line_num].split()[-1])
223223
lambda_con2 = float(lines[con2_line_num].split()[-1])
224224
if optName in ("IPOPT", "SNOPT", "ParOpt"):
225-
lambda_sign = -1.0 if optName == 'IPOPT' else 1.0
226-
assert_allclose([lambda_con1, lambda_con2],
227-
lambda_sign * np.asarray(self.lambdaStar[0]["con"]),
228-
rtol=1.0e-5, atol=1.0e-5)
225+
# IPOPT returns Lagrange multipliers with opposite sign than SNOPT and ParOpt
226+
lambda_sign = -1.0 if optName == "IPOPT" else 1.0
227+
assert_allclose(
228+
[lambda_con1, lambda_con2],
229+
lambda_sign * np.asarray(self.lambdaStar[0]["con"]),
230+
rtol=1.0e-5,
231+
atol=1.0e-5,
232+
)
229233
else:
230234
assert_allclose([lambda_con1, lambda_con2], [9.0e100, 9.0e100], rtol=1.0e-5, atol=1.0e-5)
231235

tests/testing_utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def assert_solution_allclose(self, sol, tol, partial_x=False, lambda_sign=1.0):
144144
and sol.lambdaStar is not None
145145
):
146146
lamStar = {con: lambda_sign * lam for con, lam in sol.lambdaStar.items()}
147-
assert_dict_allclose(lamStar,
148-
self.lambdaStar[self.sol_index],
149-
atol=tol, rtol=tol)
147+
assert_dict_allclose(lamStar, self.lambdaStar[self.sol_index], atol=tol, rtol=tol)
150148

151149
# test printing solution
152150
print(sol)

0 commit comments

Comments
 (0)