|
8 | 8 | # ____________________________________________________________________________________ |
9 | 9 |
|
10 | 10 | import logging |
| 11 | +import re |
11 | 12 | from io import StringIO |
12 | 13 |
|
13 | 14 | import pyomo.common.unittest as unittest |
@@ -300,23 +301,27 @@ def test_nonlinear(self): |
300 | 301 | m.x, m.g, diff_mode=mode, scale_problem=True |
301 | 302 | ) |
302 | 303 | # 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 |
305 | 306 | m.scaling_factor[m.x] = 1e16 |
306 | 307 | m.scaling_factor[m.g] = 1e16 |
307 | 308 | m.rhs.set_value(3) |
308 | 309 | for mode in all_diff_modes: |
309 | 310 | 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: |
317 | 313 | calculate_variable_from_constraint( |
318 | 314 | m.x, m.g, diff_mode=mode, scale_problem=True |
319 | 315 | ) |
| 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 |
320 | 325 |
|
321 | 326 | # Calculate the bubble point of Benzene. The first step |
322 | 327 | # computed by calculate_variable_from_constraint will make the |
|
0 commit comments