def test_canonicalize1(self):
    numpy.random.seed(1)
    f1 = numpy.random.random(mcr.mo_coeff.shape)
    u1 = numpy.linalg.svd(f1)[0]
    mo1 = numpy.dot(mcr.mo_coeff, u1)
    mo1 = lib.tag_array(mo1, orbsym=mcr.mo_coeff.orbsym)
    (mo, ci, mo_e) = mcr.canonicalize(mo1)
    e1 = numpy.einsum('ji,jk,ki', mo, f1, mo)
    self.assertAlmostEqual(e1, 44.2658681077, 7)
    self.assertAlmostEqual(lib.fp(mo_e), 5.13641661750631, 7)
    (mo, ci, mo_e) = mcr.canonicalize(mo1, eris=mcr.ao2mo(mcr.mo_coeff))
    e1 = numpy.einsum('ji,jk,ki', mo, f1, mo)
    self.assertAlmostEqual(e1, 44.2658681077, 7)
    self.assertAlmostEqual(lib.fp(mo_e), 4.120602580498917, 7)
    mcr1 = copy.copy(mcr)
    mcr1.frozen = 2
    (mo, ci, mo_e) = mcr1.canonicalize(mo1)
    self.assertAlmostEqual(lib.fp(mo_e), 6.603099940917858, 7)
    mcr1.frozen = [0, 1]
    (mo, ci, mo_e) = mcr1.canonicalize(mo1)
    self.assertAlmostEqual(lib.fp(mo_e), 6.603099940917858, 7)
    mcr1.frozen = [1, 12]
    (mo, ci, mo_e) = mcr1.canonicalize(mo1)
    self.assertAlmostEqual(lib.fp(mo_e), 5.218258435578816, 7)
def test_canonicalize1(self):
    numpy.random.seed(1)
    f1 = numpy.random.random(mcr.mo_coeff.shape)
    u1 = numpy.linalg.svd(f1)[0]
    mo1 = numpy.dot(mcr.mo_coeff, u1)
    mo1 = lib.tag_array(mo1, orbsym=mcr.mo_coeff.orbsym)
    (mo, ci, mo_e) = mcr.canonicalize(mo1)
    e1 = numpy.einsum('ji,jk,ki', mo, f1, mo)
    self.assertAlmostEqual(e1, 44.2658681077, 7)
    self.assertAlmostEqual(lib.fp(mo_e), 5.13641661750631, 7)
    (mo, ci, mo_e) = mcr.canonicalize(mo1, eris=mcr.ao2mo(mcr.mo_coeff))
    e1 = numpy.einsum('ji,jk,ki', mo, f1, mo)
    self.assertAlmostEqual(e1, 44.2658681077, 7)
    self.assertAlmostEqual(lib.fp(mo_e), 4.120602580498917, 7)
    mcr1 = copy.copy(mcr)
    mcr1.frozen = 2
    (mo, ci, mo_e) = mcr1.canonicalize(mo1)
    self.assertAlmostEqual(lib.fp(mo_e), 6.603099940917858, 7)
    mcr1.frozen = [0, 1]
    (mo, ci, mo_e) = mcr1.canonicalize(mo1)
    self.assertAlmostEqual(lib.fp(mo_e), 6.603099940917858, 7)
    mcr1.frozen = [1, 12]
    (mo, ci, mo_e) = mcr1.canonicalize(mo1)
    self.assertAlmostEqual(lib.fp(mo_e), 5.218258435578816, 7)