2525 _SMALL_TOLERANCE_SYMMETRY ,
2626 _SMALL_TOLERANCE_IMG ,
2727)
28+
2829if not (numpy_available and scipy_available ):
2930 raise unittest .SkipTest ("Pyomo.DoE needs scipy and numpy to run tests" )
3031
@@ -172,6 +173,7 @@ def test_get_FIM_metrics(self):
172173 fim_metrics ["log10(Modified E-Optimality)" ], expected ['ME_opt' ]
173174 )
174175
176+
175177@unittest .skipIf (not ipopt_available , "The 'ipopt' command is not available" )
176178@unittest .skipIf (not numpy_available , "Numpy is not available" )
177179class TestExperimentGradients (unittest .TestCase ):
@@ -278,16 +280,15 @@ def test_polynomial_automatic_only_still_sets_both_jacobians(self):
278280 model , symbolic = False , automatic = True
279281 )
280282
281- jacobian = (
283+ jacobian = (
282284 experiment_gradients .compute_gradient_outputs_wrt_unknown_parameters ()
283285 )
284286 expected = self ._get_expected_polynomial_gradient ()
285287
286288 self .assertIsNotNone (experiment_gradients .jac_dict_sd )
287289 self .assertIsNotNone (experiment_gradients .jac_dict_ad )
288290 self .assertEqual (jacobian .shape , expected .shape )
289- self .assertTrue (np .allclose (jacobian ,expected ))
290-
291+ self .assertTrue (np .allclose (jacobian , expected ))
291292
292293 def test_polynomial_symbolic_only_still_sets_both_jacobians (self ):
293294 """Check that symbolic-only requests still initialize both Jacobian maps."""
@@ -298,7 +299,7 @@ def test_polynomial_symbolic_only_still_sets_both_jacobians(self):
298299 model , symbolic = True , automatic = False
299300 )
300301
301- jacobian = (
302+ jacobian = (
302303 experiment_gradients .compute_gradient_outputs_wrt_unknown_parameters ()
303304 )
304305 expected = self ._get_expected_polynomial_gradient ()
@@ -343,19 +344,20 @@ def test_rooney_biegler_gradients_match_closed_form(self):
343344 self .assertEqual (jacobian .shape , expected .shape )
344345 self .assertTrue (np .allclose (jacobian , expected , atol = 1e-7 , rtol = 1e-7 ))
345346
346-
347-
348347 @unittest .skipIf (not scipy_available , "scipy is not available" )
349348 @unittest .skipIf (not ipopt_available , "The 'ipopt' command is not available" )
350- def test_rooney_biegler_symbolic_and_automatic_jacobians_agree_at_perturbed_point (self ):
349+ def test_rooney_biegler_symbolic_and_automatic_jacobians_agree_at_perturbed_point (
350+ self ,
351+ ):
351352 """Check Rooney-Biegler Jacobian agreement at a perturbed operating point."""
352- experiment = self ._get_rooney_biegler_experiment (hour = 7.0 , y = 19.8 , asymptote = 14.0 , rate_constant = 0.4 )
353+ experiment = self ._get_rooney_biegler_experiment (
354+ hour = 7.0 , y = 19.8 , asymptote = 14.0 , rate_constant = 0.4
355+ )
353356 model = experiment .get_labeled_model ()
354357
355358 experiment_gradients = self ._assert_symbolic_and_automatic_jacobians_agree (
356359 model , atol = 1e-6 , rtol = 1e-6
357360 )
358-
359361
360362 self .assertGreater (len (experiment_gradients .jac_dict_sd ), 0 )
361363 self .assertEqual (
0 commit comments