Skip to content

Commit 41b8b0a

Browse files
Merge branch 'clip_calculate_variable' into scale_temporary_block
2 parents f10283d + dbf30f8 commit 41b8b0a

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

pyomo/util/tests/test_calc_var_value.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# ____________________________________________________________________________________
99

1010
import logging
11+
import re
1112
from io import StringIO
1213

1314
import pyomo.common.unittest as unittest
@@ -300,23 +301,27 @@ def test_nonlinear(self):
300301
m.x, m.g, diff_mode=mode, scale_problem=True
301302
)
302303
# Here, because both the variable and constraint are scaled, we don't terminate due to
303-
# a zero derivative. It still raises an error, however, because we're asking for an
304-
# unreasonable amount of precision
304+
# a zero derivative. It still raises an error on some platforms, however, because we're
305+
# asking for an unreasonable amount of precision
305306
m.scaling_factor[m.x] = 1e16
306307
m.scaling_factor[m.g] = 1e16
307308
m.rhs.set_value(3)
308309
for mode in all_diff_modes:
309310
m.x.set_value(1)
310-
with self.assertRaisesRegex(
311-
IterationLimitError,
312-
"Linesearch iteration limit reached solving for variable 'x' using "
313-
"constraint 'g'; remaining residual = "
314-
+ SCIENTIFIC_NOTATION_REGEX
315-
+ r"\.",
316-
):
311+
312+
try:
317313
calculate_variable_from_constraint(
318314
m.x, m.g, diff_mode=mode, scale_problem=True
319315
)
316+
except IterationLimitError as err:
317+
out = re.match(
318+
"Linesearch iteration limit reached solving for variable 'x' using "
319+
"constraint 'g'; remaining residual = "
320+
+ SCIENTIFIC_NOTATION_REGEX
321+
+ r"\.",
322+
err.message,
323+
)
324+
assert out is not None
320325

321326
# Calculate the bubble point of Benzene. The first step
322327
# computed by calculate_variable_from_constraint will make the

0 commit comments

Comments
 (0)