def test_scalar_sizes(self):
        class A(Component):
            def __init__(self):
                super(A, self).__init__()
                self.add_param('x', shape=1)
                self.add_output('y', shape=1)

        class B(Component):
            def __init__(self):
                super(B, self).__init__()
                self.add_param('x', shape=2)
                self.add_output('y', shape=2)

        class C(Component):
            def __init__(self):
                super(C, self).__init__()
                self.add_param('x', shape=3)
                self.add_output('y', shape=3)

        # Scalar Values
        prob = Problem()
        root = prob.root = Group()
        root.add('X', IndepVarComp('x', 0., shape=1), promotes=['x'])
        root.add('A1', A(), promotes=['x'])
        root.add('A2', A())
        root.connect('A1.y', 'A2.x')
        prob.setup(check=False)

        # Array Values
        prob = Problem()
        root = prob.root = Group()
        root.add('X', IndepVarComp('x', np.zeros(2), shape=2), promotes=['x'])
        root.add('B1', B(), promotes=['x'])
        root.add('B2', B())
        root.connect('B1.y', 'B2.x')
        prob.setup(check=False)

        # Mismatched Array Values
        prob = Problem()
        root = prob.root = Group()
        root.add('X', IndepVarComp('x', np.zeros(2), shape=2), promotes=['x'])
        root.add('B1', B(), promotes=['x'])
        root.add('C1', C())
        root.connect('B1.y', 'C1.x')
        with self.assertRaises(Exception) as cm:
            prob.setup(check=False)
        expected = "Shape (2,) of source 'B1.y' must be the same as " \
                   "shape (3,) of target 'C1.x'."
        self.assertTrue(str(cm.exception) in expected)

        # Mismatched Scalar to Array Value
        prob = Problem()
        root = prob.root = Group()
        root.add('X', IndepVarComp('x', 0., shape=1), promotes=['x'])
        root.add('B1', B(), promotes=['x'])
        with self.assertRaises(Exception) as cm:
            prob.setup(check=False)

        expected = py3fix("Type <type 'float'> of source 'X.x' (x) must be the same as "
                          "type <type 'numpy.ndarray'> of target 'B1.x' (x).")
        self.assertEqual(expected, str(cm.exception))
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/core/test/test_problem.py/TestProblem.test_scalar_sizes/swapped operands of `in`