def test_set_logical_states_none(self): c0 = Cavity("c0", levels=6) c1 = Cavity("c1", levels=10) c0.set_logical_states(None, None) c1.set_logical_states(None, None) self.assertEqual(c0.logical_zero(), c0.basis(0)) self.assertEqual(c0.logical_one(), c0.basis(1)) self.assertEqual(c1.logical_zero(), c1.basis(0)) self.assertEqual(c1.logical_one(), c1.basis(1))
def test_paulis_custom_logical_states(self): c0 = Cavity("c0", levels=6) c1 = Cavity("c1", levels=10) c0.set_logical_states(c0.basis(0), c0.basis(1)) c1.set_logical_states(c1.basis(2), c1.basis(3)) c0_0 = c0.logical_zero(full_space=False) c0_1 = c0.logical_one(full_space=False) c1_0 = c1.logical_zero(full_space=False) c1_1 = c1.logical_one(full_space=False) c0_I = c0.I c1_I = c1.I single_mode_paulis = { "X0": c0_0 * c0_1.dag() + c0_1 * c0_0.dag(), "X1": c1_0 * c1_1.dag() + c1_1 * c1_0.dag(), "Y0": -1j * (c0_0 * c0_1.dag() - c0_1 * c0_0.dag()), "Y1": -1j * (c1_0 * c1_1.dag() - c1_1 * c1_0.dag()), "Z0": c0_0 * c0_0.dag() - c0_1 * c0_1.dag(), "Z1": c1_0 * c1_0.dag() - c1_1 * c1_1.dag(), } c0.space = c1.space = [c1, c0] self.assertEqual(c0.sigmax(full_space=False), single_mode_paulis["X0"]) self.assertEqual(c0.sigmay(full_space=False), single_mode_paulis["Y0"]) self.assertEqual(c0.sigmaz(full_space=False), single_mode_paulis["Z0"]) self.assertEqual(c1.sigmax(full_space=False), single_mode_paulis["X1"]) self.assertEqual(c1.sigmay(full_space=False), single_mode_paulis["Y1"]) self.assertEqual(c1.sigmaz(full_space=False), single_mode_paulis["Z1"]) self.assertEqual(c0.sigmax(full_space=True), qutip.tensor(c1_I, single_mode_paulis["X0"])) self.assertEqual(c0.sigmay(full_space=True), qutip.tensor(c1_I, single_mode_paulis["Y0"])) self.assertEqual(c0.sigmaz(full_space=True), qutip.tensor(c1_I, single_mode_paulis["Z0"])) self.assertEqual(c1.sigmax(full_space=True), qutip.tensor(single_mode_paulis["X1"], c0_I)) self.assertEqual(c1.sigmay(full_space=True), qutip.tensor(single_mode_paulis["Y1"], c0_I)) self.assertEqual(c1.sigmaz(full_space=True), qutip.tensor(single_mode_paulis["Z1"], c0_I))