def test_fock_prob(self, tol): """Test fock_prob returns the correct Fock probabilities""" # an arbitrary two-mode Gaussian state generated using Strawberry Fields mu = np.array([0.6862, 0.4002, 0.09, 0.558]) * np.sqrt(hbar) cov = np.array( [[0.50750512, -0.04125979, -0.21058229, -0.07866912], [-0.04125979, 0.50750512, -0.07866912, -0.21058229], [-0.21058229, -0.07866912, 0.95906208, 0.27133391], [-0.07866912, -0.21058229, 0.27133391, 0.95906208]] ) * hbar # expected Fock state probabilities events = [(0, 0), (0, 1), (1, 1), (2, 3)] probs = [0.430461524043, 0.163699407559, 0.0582788388927, 0.00167706931355] for idx, e in enumerate(events): res = fock_prob(mu, cov, e, hbar=hbar) assert res == pytest.approx(probs[idx], abs=tol)
def test_fock_prob(self): """Test fock_prob returns the correct Fock probabilities""" for idx, e in enumerate(self.events): res = fock_prob(self.mu, self.cov, e, hbar=self.hbar) self.assertAlmostEqual(res, self.probs[idx], delta=self.tol)