def test_measurement_noncommuting(): """ Test measurements of stabilizer state from tableau This tests the non-commuting measurement operator """ # generate bell state then measure each qubit sequentially prog = Program().inst(H(0)).measure(0, 0) qvmstab = QVM_Stabilizer() results = qvmstab.run(prog, trials=5000) assert np.isclose(np.mean(results), 0.5, rtol=0.1)
def test_measurement_commuting(): """ Test measuremt of stabilzier state from tableau This tests when the measurement operator commutes with the stabilizers To test we will first test draw's from a blank stabilizer and then with X """ identity_program = Program().inst([I(0)]).measure(0, 0) qvmstab = QVM_Stabilizer() results = qvmstab.run(identity_program, trials=1000) assert all(np.array(results) == 0)
def test_measurement_commuting_result_one(): """ Test measuremt of stabilzier state from tableau This tests when the measurement operator commutes with the stabilizers This time we will generate the stabilizer -Z|1> = |1> so we we need to do a bitflip...not just identity. A Bitflip is HSSH = X """ identity_program = Program().inst([H(0), S(0), S(0), H(0)]).measure(0, 0) qvmstab = QVM_Stabilizer() results = qvmstab.run(identity_program, trials=1000) assert all(np.array(results) == 1)
def test_bell_state_measurements(): prog = Program().inst(H(0), CNOT(0, 1)).measure(0, 0).measure(1, 1) qvmstab = QVM_Stabilizer() results = qvmstab.run(prog, trials=5000) assert np.isclose(np.mean(results), 0.5, rtol=0.1) assert all([x[0] == x[1] for x in results])