'Test matmul function, corresponding to .__matmul__( operator.'

def test_matmul_expression(self):

    if PY35:
        c = Constant([[2], [2]])
        exp = c.__matmul__(self.x)
        self.assertEqual(exp.curvature, s.AFFINE)
        self.assertEqual(exp.sign, s.UNKNOWN)
        self.assertEqual(exp.canonical_form[0].size, (1, 1))
        self.assertEqual(exp.canonical_form[1], [])
        self.assertEqual(exp.size, (1, 1))
        with self.assertRaises(Exception) as cm:
            self.x.__matmul__(2)
        self.assertEqual(str(cm.exception), "Scalar    operands    are    not    allowed,    use    '*'    instead")
        with self.assertRaises(Exception) as cm:
            self.x.__matmul__(np.array([2, 2, 3]))
        self.assertEqual(str(cm.exception), 'Incompatible    dimensions    (2,    1)    (3,    1)')
        with self.assertRaises(Exception) as cm:
            Constant([[2, 1], [2, 2]]).__matmul__(self.C)
        self.assertEqual(str(cm.exception), 'Incompatible    dimensions    (2,    2)    (3,    2)')
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            q = self.A.__matmul__(self.B)
            self.assertTrue(q.is_quadratic())
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            with self.assertRaises(Exception) as cm:
                self.A.__matmul__(self.B).__matmul__(self.A)
            self.assertEqual(str(cm.exception), 'Cannot    multiply    UNKNOWN    and    AFFINE.')
        T = Constant([[1, 2, 3], [3, 5, 5]])
        exp = (T + T).__matmul__(self.B)
        self.assertEqual(exp.curvature, s.AFFINE)
        self.assertEqual(exp.size, (3, 2))
        c = Constant([[2], [2], [(-2)]])
        exp = ([[1], [2]] + c.__matmul__(self.C))
        self.assertEqual(exp.sign, s.UNKNOWN)
    else:
        pass
