def test_error_msg_vectorized(self):
    x_bp = np.array([0.0, 1.0])
    y_data = np.array([0.0, 4.0])
    nn = 5

    class MMComp(om.MetaModelStructuredComp):

        def setup(self):
            nn = self.options['vec_size']
            self.add_input(name='x', val=np.ones(nn), units=None, training_data=x_bp)
            self.add_output(name='y', val=np.zeros(nn), units=None, training_data=y_data)
    p = om.Problem()
    ivc = om.IndepVarComp()
    ivc.add_output('x', val=np.linspace(0.5, 1.1, nn))
    p.model.add_subsystem('ivc', ivc, promotes=['x'])
    p.model.add_subsystem('MM', MMComp(vec_size=nn), promotes=['x', 'y'])
    p.setup()
    with self.assertRaises(om.AnalysisError) as cm:
        p.run_model()
    msg = "'MM' <class MMComp>: Error interpolating output 'y' because input 'MM.x' was out of bounds ('0.0', '1.0') with value '1.1'"
    self.assertEqual(str(cm.exception), msg)
def test_error_msg_vectorized(self):
    x_bp = np.array([0.0, 1.0])
    y_data = np.array([0.0, 4.0])
    nn = 5

    class MMComp(om.MetaModelStructuredComp):

        def setup(self):
            nn = self.options['vec_size']
            self.add_input(name='x', val=np.ones(nn), units=None, training_data=x_bp)
            self.add_output(name='y', val=np.zeros(nn), units=None, training_data=y_data)
    p = om.Problem()
    ivc = om.IndepVarComp()
    ivc.add_output('x', val=np.linspace(0.5, 1.1, nn))
    p.model.add_subsystem('ivc', ivc, promotes=['x'])
    p.model.add_subsystem('MM', MMComp(vec_size=nn), promotes=['x', 'y'])
    p.setup()
    with self.assertRaises(om.AnalysisError) as cm:
        p.run_model()
    msg = "'MM' <class MMComp>: Error interpolating output 'y' because input 'MM.x' was out of bounds ('0.0', '1.0') with value '1.1'"
    self.assertEqual(str(cm.exception), msg)