def test_expand(self): """Test expand method.""" rho0, rho1 = np.diag([1, 0]), np.diag([0, 1]) rho_init = DensityMatrix(np.kron(rho0, rho0)) chan1 = Stinespring(self.UI) chan2 = Stinespring(self.UX) # X \otimes I chan = chan1.expand(chan2) rho_targ = DensityMatrix(np.kron(rho1, rho0)) self.assertEqual(chan.dim, (4, 4)) self.assertEqual(rho_init.evolve(chan), rho_targ) # I \otimes X chan = chan2.expand(chan1) rho_targ = DensityMatrix(np.kron(rho0, rho1)) self.assertEqual(chan.dim, (4, 4)) self.assertEqual(rho_init.evolve(chan), rho_targ) # Completely depolarizing chan_dep = Stinespring(self.depol_stine(1)) chan = chan_dep.expand(chan_dep) rho_targ = DensityMatrix(np.diag([1, 1, 1, 1]) / 4) self.assertEqual(chan.dim, (4, 4)) self.assertEqual(rho_init.evolve(chan), rho_targ)
def test_expand(self): """Test expand method.""" rho0, rho1 = np.diag([1, 0]), np.diag([0, 1]) rho_init = np.kron(rho0, rho0) chan1 = Stinespring(self.matI) chan2 = Stinespring(self.matX) # X \otimes I chan = chan1.expand(chan2) rho_targ = np.kron(rho1, rho0) self.assertEqual(chan.dims, (4, 4)) self.assertAllClose(chan._evolve(rho_init), rho_targ) # I \otimes X chan = chan2.expand(chan1) rho_targ = np.kron(rho0, rho1) self.assertEqual(chan.dims, (4, 4)) self.assertAllClose(chan._evolve(rho_init), rho_targ) # Completely depolarizing chan_dep = Stinespring(self.depol_stine(1)) chan = chan_dep.expand(chan_dep) rho_targ = np.diag([1, 1, 1, 1]) / 4 self.assertEqual(chan.dims, (4, 4)) self.assertAllClose(chan._evolve(rho_init), rho_targ)