Пример #1
0
class TestAddNonexistentVar(unittest.TestCase):
    def setUp(self):
        self.nn = 3
        self.p = Problem(model=Group())
        self.ivc = DictIndepVarComp(data_dict=data)
        self.ivc.add_output(name='a', shape=(self.nn,))
        self.ivc.add_output(name='b', shape=(self.nn,))

    def test_nonexistent_key(self):
        self.assertRaises(KeyError,self.ivc.add_output_from_dict,'geom|S_ref_blah')

    def test_no_value(self):
        self.assertRaises(KeyError,self.ivc.add_output_from_dict,'geom|noval')
    def setUp(self):
        self.nn = 3
        self.p = Problem(model=Group())
        ivc = DictIndepVarComp(data_dict=data)
        ivc.add_output(name='a', shape=(self.nn, ))
        ivc.add_output(name='b', shape=(self.nn, ))
        ivc.add_output_from_dict('geom|S_ref')
        ivc.add_output_from_dict('aero|CLmax|flaps30')
        ivc.add_output_from_dict('aero|CLmax|flaps10')

        self.p.model.add_subsystem(name='ivc',
                                   subsys=ivc,
                                   promotes_outputs=['*'])

        self.p.setup()

        self.p['a'] = np.random.rand(self.nn, )
        self.p['b'] = np.random.rand(self.nn, )

        self.p.run_model()