def test_mode_auto(self): # Make sure mode=auto chooses correctly for all prob sizes as well # as for abs/rel/etc paths prob = Problem() root = prob.root = Group() root.add("p1", ParamComp("a", 1.0), promotes=["*"]) root.add("p2", ParamComp("b", 1.0), promotes=["*"]) root.add("comp", ExecComp(["x = 2.0*a + 3.0*b", "y=4.0*a - 1.0*b"]), promotes=["*"]) root.ln_solver.options["mode"] = "auto" prob.setup(check=False) prob.run() mode = prob._mode("auto", ["a"], ["x"]) self.assertEqual(mode, "fwd") mode = prob._mode("auto", ["a", "b"], ["x"]) self.assertEqual(mode, "rev") # make sure _check function does it too # try: # mode = prob._check_for_matrix_matrix(['a'], ['x']) # except Exception as err: # msg = "Group '' must have the same mode as root to use Matrix Matrix." # self.assertEqual(text_type(err), msg) # else: # self.fail('Exception expected') root.ln_solver.options["mode"] = "fwd" mode = prob._check_for_matrix_matrix(["a", "b"], ["x"]) self.assertEqual(mode, "fwd")
def test_mode_auto(self): # Make sure mode=auto chooses correctly for all prob sizes as well # as for abs/rel/etc paths prob = Problem() root = prob.root = Group() root.add('p1', ParamComp('a', 1.0), promotes=['*']) root.add('p2', ParamComp('b', 1.0), promotes=['*']) root.add('comp', ExecComp(['x = 2.0*a + 3.0*b', 'y=4.0*a - 1.0*b']), promotes=['*']) root.ln_solver.options['mode'] = 'auto' prob.setup(check=False) prob.run() mode = prob._mode('auto', ['a'], ['x']) self.assertEqual(mode, 'fwd') mode = prob._mode('auto', ['a', 'b'], ['x']) self.assertEqual(mode, 'rev') # make sure _check function does it too #try: #mode = prob._check_for_matrix_matrix(['a'], ['x']) #except Exception as err: #msg = "Group '' must have the same mode as root to use Matrix Matrix." #self.assertEqual(text_type(err), msg) #else: #self.fail('Exception expected') root.ln_solver.options['mode'] = 'fwd' mode = prob._check_for_matrix_matrix(['a', 'b'], ['x']) self.assertEqual(mode, 'fwd')