@unittest.skipIf(((OPT is None) or (OPTIMIZER is None)), 'only run if pyoptsparse is installed.')
def test_analysis_error_warning_msg(self):
    x_tr = np.linspace(0, (2 * np.pi), 100)
    y_tr = np.sin(x_tr)
    p = om.Problem(model=om.Group())
    p.driver = om.pyOptSparseDriver(optimizer=OPTIMIZER)
    mm = om.MetaModelStructuredComp(extrapolate=False)
    mm.add_input('x', val=1.0, training_data=x_tr)
    mm.add_output('y', val=1.0, training_data=y_tr)
    p.model.add_subsystem('interp', mm, promotes_inputs=['x'], promotes_outputs=['y'])
    p.model.add_objective('y', scaler=(- 1))
    p.model.add_design_var('x', lower=6, upper=10)
    p.set_solver_print(level=0)
    p.setup()
    p.set_val('x', 0.75)
    msg = "Analysis Error: 'interp' <class MetaModelStructuredComp> Line 203 of file {}".format(inspect.getsourcefile(om.MetaModelStructuredComp))
    with assert_warning(UserWarning, msg):
        p.run_driver()
@unittest.skipIf(((OPT is None) or (OPTIMIZER is None)), 'only run if pyoptsparse is installed.')
def test_analysis_error_warning_msg(self):
    x_tr = np.linspace(0, (2 * np.pi), 100)
    y_tr = np.sin(x_tr)
    p = om.Problem(model=om.Group())
    p.driver = om.pyOptSparseDriver(optimizer=OPTIMIZER)
    mm = om.MetaModelStructuredComp(extrapolate=False)
    mm.add_input('x', val=1.0, training_data=x_tr)
    mm.add_output('y', val=1.0, training_data=y_tr)
    p.model.add_subsystem('interp', mm, promotes_inputs=['x'], promotes_outputs=['y'])
    p.model.add_objective('y', scaler=(- 1))
    p.model.add_design_var('x', lower=6, upper=10)
    p.set_solver_print(level=0)
    p.setup()
    p.set_val('x', 0.75)
    msg = "Analysis Error: 'interp' <class MetaModelStructuredComp> Line 203 of file {}".format(inspect.getsourcefile(om.MetaModelStructuredComp))
    with assert_warning(UserWarning, msg):
        p.run_driver()