From e7bfad9be7b7e374560faa886f4cdca925c3cf72 Mon Sep 17 00:00:00 2001 From: Bernard Knueven Date: Thu, 20 Jun 2024 11:59:36 -0600 Subject: [PATCH] fix tests --- .../algorithms/solvers/tests/test_cyipopt_interfaces.py | 6 +++--- .../interfaces/tests/test_external_grey_box_model.py | 8 ++++---- .../pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyomo/contrib/pynumero/algorithms/solvers/tests/test_cyipopt_interfaces.py b/pyomo/contrib/pynumero/algorithms/solvers/tests/test_cyipopt_interfaces.py index 88d4df1e17d..9d2c961a69d 100644 --- a/pyomo/contrib/pynumero/algorithms/solvers/tests/test_cyipopt_interfaces.py +++ b/pyomo/contrib/pynumero/algorithms/solvers/tests/test_cyipopt_interfaces.py @@ -156,9 +156,9 @@ def test_model1_CyIpoptNLP_scaling(self): cynlp = CyIpoptNLP(PyomoNLP(m)) obj_scaling, x_scaling, g_scaling = cynlp.scaling_factors() - self.assertTrue(obj_scaling is None) - self.assertTrue(x_scaling is None) - self.assertTrue(g_scaling is None) + self.assertTrue(obj_scaling == 1.0) + self.assertTrue((x_scaling == 1.0).all()) + self.assertTrue((g_scaling == 1.0).all()) def _check_model1(self, nlp, cynlp): # test x_init diff --git a/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py b/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py index 0fc342c4e40..188aba30eeb 100644 --- a/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py +++ b/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py @@ -1827,7 +1827,7 @@ def create_model_two_equalities_two_outputs(self, external_model): m.egb.outputs['Pout'].setub(70) return m - def test_scaling_all_missing(self): + def test_scaling_all_one(self): m = self.create_model_two_equalities_two_outputs( ex_models.PressureDropTwoEqualitiesTwoOutputs() ) @@ -1836,9 +1836,9 @@ def test_scaling_all_missing(self): fs = pyomo_nlp.get_obj_scaling() xs = pyomo_nlp.get_primals_scaling() cs = pyomo_nlp.get_constraints_scaling() - self.assertIsNone(fs) - self.assertIsNone(xs) - self.assertIsNone(cs) + self.assertEqual(fs, 1.0) + self.assertTrue((xs == 1.0).all()) + self.assertTrue((cs == 1.0).all()) def test_scaling_pyomo_model_only(self): m = self.create_model_two_equalities_two_outputs( diff --git a/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py b/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py index ecadf40e5cf..1dcdc2a6237 100644 --- a/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py +++ b/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py @@ -2248,7 +2248,7 @@ def create_model_two_equalities_two_outputs(self, external_model): m.egb.outputs['Pout'].setub(70) return m - def test_scaling_all_missing(self): + def test_scaling_all_one(self): m = self.create_model_two_equalities_two_outputs( ex_models.PressureDropTwoEqualitiesTwoOutputs() ) @@ -2257,9 +2257,9 @@ def test_scaling_all_missing(self): fs = pyomo_nlp.get_obj_scaling() xs = pyomo_nlp.get_primals_scaling() cs = pyomo_nlp.get_constraints_scaling() - self.assertIsNone(fs) - self.assertIsNone(xs) - self.assertIsNone(cs) + self.assertEqual(fs, 1.0) + self.assertTrue((xs == 1.0).all()) + self.assertTrue((cs == 1.0).all()) def test_scaling_pyomo_model_only(self): m = self.create_model_two_equalities_two_outputs(