'Test the PSD constraint <<.'

def test_psd_constraint(self):

    constr = (self.A >> self.B)
    self.assertEqual(constr.name(), 'A    >>    B')
    self.assertEqual(constr.size, (2, 2))
    assert (constr.dual_value is None)
    assert (constr.value is None)
    self.A.save_value(np.matrix('2    -1;    1    2'))
    self.B.save_value(np.matrix('1    0;    0    1'))
    assert constr.value
    self.assertAlmostEqual(constr.violation, 0)
    self.assertAlmostEqual(constr.residual.value, 0)
    self.B.save_value(np.matrix('3    0;    0    3'))
    assert (not constr.value)
    self.assertAlmostEqual(constr.violation, 1)
    self.assertAlmostEqual(constr.residual.value, 1)
    with self.assertRaises(Exception) as cm:
        (self.x >> self.y)
    self.assertEqual(str(cm.exception), 'Non-square    matrix    in    positive    definite    constraint.')
    copy = constr.copy()
    self.assertTrue((type(copy) is type(constr)))
    self.assertEqual(copy.args, constr.args)
    self.assertFalse((copy.args is constr.args))
    copy = constr.copy(args=[self.B, self.A])
    self.assertTrue((type(copy) is type(constr)))
    self.assertTrue((copy.args[0] is self.B))
    self.assertTrue((copy.args[1] is self.A))
