def test_thermal_loss_channel(self, setup_eng, tol): """Test thermal loss channel with no transmission produces thermal state""" eng, prog = setup_eng(1) nbar = 0.43 with prog.context as q: ops.Dgate(A) | q[0] ops.ThermalLossChannel(0, nbar) | q[0] state = eng.run(prog).state mean_photon, var = state.mean_photon(0) assert np.allclose(mean_photon, nbar, atol=tol, rtol=0) assert np.allclose(var, nbar**2 + nbar, atol=tol, rtol=0)
def test_thermalloss_merging_different_nbar(self, tol): """test the merging of two Loss channels with same nbar raises exception""" G = ops.ThermalLossChannel(a, 2 * c) with pytest.raises(MergeFailure): merged = G.merge(ops.ThermalLossChannel(b, c))
def test_thermalloss_merging_different_nbar(self, tol): """test the merging of Loss and ThermalLoss raises exception""" G = ops.ThermalLossChannel(a, 2 * c) with pytest.raises(MergeFailure): merged = G.merge(ops.LossChannel(b))
def test_thermalloss_merging_same_nbar(self, tol): """test the merging of two Loss channels with same nbar""" G = ops.ThermalLossChannel(a, c) merged = G.merge(ops.ThermalLossChannel(b, c)) assert np.allclose(merged.p[0], a * b, atol=tol, rtol=0)