def test_two_mode_squeezed_expval(self): """Checking that the expectation value of samples matches if there was correlation.""" mode1 = [0] mode2 = [1] samples = entangled_gaussian_samples() expval1 = samples_expectation(samples, mode1) expval2 = samples_expectation(samples, mode2) assert expval1 == expval2
def expval(self, observable, wires, par): if observable == "Identity": return 1 return samples_expectation(self.samples, modes=self.map_wires(wires))
def test_fock_backend_integration_expval(self, expval, modes): """Checking the expectation values when fock states were sampled with a single shot.""" samples = fock_states_samples() assert samples_expectation(samples, modes) == expval
def test_fock_backend_integration_modes_implicit(self): """Checking the expectation values when modes are specified implicitly.""" samples = fock_states_samples() expval = 2 * 3 * 4 assert samples_expectation(samples) == expval
def test_quadrature_expval(self, samples, expval): """Checking the expectation value of pre-defined homodyne samples.""" assert np.isclose(samples_expectation(samples), expval)