def test_homodyne_measurement_vacuum(self, setup_eng, tol): """MeasureX and MeasureP leave the mode in the vacuum state""" eng, prog = setup_eng(2) with prog.context as q: ops.Coherent(a, c) | q[0] ops.Coherent(b, c) | q[1] ops.MeasureX | q[0] ops.MeasureP | q[1] eng.run(prog) assert np.all(eng.backend.is_vacuum(tol))
def test_heterodyne(self, setup_eng, tol): """Test Fock measurements return expected results""" eng, prog = setup_eng(2) a = [0.43 - 0.12j, 0.02 + 0.2j] with prog.context as q: ops.Coherent(a[0]) | q[0] ops.Coherent(a[1]) | q[1] ops.MeasureHD | q[0] ops.MeasureHD | q[1] eng.run(prog) # Heterodyne measurements put the modes into vacuum state assert eng.backend.is_vacuum(tol)
def test_heterodyne(self, setup_eng, tol): """Test heterodyne measurements return expected results""" eng, prog = setup_eng(2) a0 = 0.44643 phi0 = -0.2721457 a1 = 0.200998 phi1 = 1.47112755 with prog.context as q: ops.Coherent(a0, phi0) | q[0] ops.Coherent(a1, phi1) | q[1] ops.MeasureHD | q[0] ops.MeasureHD | q[1] eng.run(prog) # Heterodyne measurements put the modes into vacuum state assert eng.backend.is_vacuum(tol)
def test_homodyne_measurement_vacuum_phi(self, setup_eng, tol): """Homodyne measurements leave the mode in the vacuum state""" eng, prog = setup_eng(2) with prog.context as q: ops.Coherent(a, b) | q[0] ops.MeasureHomodyne(c) | q[0] eng.run(prog) assert np.all(eng.backend.is_vacuum(tol))
def test_coherent_state_has_photons(self, setup_eng, hbar): """Test that a coherent state with a mean photon number of 4 and sampled 100 times will produce photons""" shots = 100 eng, prog = setup_eng(1) alpha = 2 with prog.context as q: ops.Coherent(alpha) | q[0] ops.MeasureFock() | q[0] state = eng.run(prog).state samples = np.array(eng.run(prog, shots=shots)).flatten() assert not np.all(samples == np.zeros_like(samples, dtype=int))