def test_measure_nondeterministic_without_sampling(self): """Test QasmSimulator measure with non-deterministic counts without sampling""" shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) targets = ref_measure.measure_counts_nondeterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots) result = self.SIMULATOR.run(qobj, **self.BACKEND_OPTS).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_measure_nondeterministic_without_sampling(self): """Test ExtendedStabilizer measure with non-deterministic counts without sampling""" shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) qobj = assemble(circuits, QasmSimulator(), shots=shots) targets = ref_measure.measure_counts_nondeterministic(shots) job = QasmSimulator().run(qobj, **self.BACKEND_OPTS) result = job.result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_measure_nondeterministic_with_sampling(self): """Test CHimulator measure with non-deterministic counts with sampling""" shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=True) qobj = assemble(circuits, QasmSimulator(), shots=shots) targets = ref_measure.measure_counts_nondeterministic(shots) job = QasmSimulator().run(qobj, backend_options=self.BACKEND_OPTS_SAMPLING) result = job.result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_measure_nondeterministic_with_sampling(self): """Test QasmSimulator measure with non-deterministic counts with sampling""" shots = 2000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=True) targets = ref_measure.measure_counts_nondeterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots) result = self.SIMULATOR.run( qobj, backend_options=self.BACKEND_OPTS).result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_measure_nondeterministic_without_sampling(self): """Test CHimulator measure with non-deterministic counts without sampling""" shots = 2000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) qobj = assemble(circuits, QasmSimulator(), shots=shots) targets = ref_measure.measure_counts_nondeterministic(shots) job = QasmSimulator().run(qobj, backend_options=self.BACKEND_OPTS) result = job.result() self.assertTrue(getattr(result, 'success', False)) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_measure_nondeterministic_without_sampling(self): """Test CHimulator measure with non-deterministic counts without sampling""" shots = 2000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) qobj = assemble(circuits, QasmSimulator(), shots=shots) targets = ref_measure.measure_counts_nondeterministic(shots) job = QasmSimulator().run( qobj, backend_options={"method": "extended_stabilizer"}) result = job.result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots)
def test_measure_nondeterministic_without_sampling(self): """Test QasmSimulator measure with nin-deterministic counts without sampling""" shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) targets = ref_measure.measure_counts_nondeterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots) result = self.SIMULATOR.run( qobj, backend_options=self.BACKEND_OPTS).result() self.assertTrue(getattr(result, 'success', False)) self.compare_counts(result, circuits, targets, delta=0.05 * shots) self.compare_result_metadata(result, circuits, "measure_sampling", False)
def test_measure_nondeterministic_without_sampling(self, method, device): """Test AerSimulator measure with non-deterministic counts without sampling""" backend = self.backend(method=method, device=device) shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) targets = ref_measure.measure_counts_nondeterministic(shots) result = backend.run(circuits, shots=shots).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots) self.compare_result_metadata(result, circuits, "measure_sampling", False)
def test_measure_nondeterministic_with_sampling(self, method, device): """Test AerSimulator measure with non-deterministic counts with sampling""" backend = self.backend(method=method, device=device) shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=True) targets = ref_measure.measure_counts_nondeterministic(shots) result = backend.run(circuits, shots=shots).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots) # Test sampling was enabled for res in result.results: self.assertIn("measure_sampling", res.metadata) self.assertEqual(res.metadata["measure_sampling"], True)
def test_measure_nondeterministic_without_sampling(self): """Test QasmSimulator measure with nin-deterministic counts without sampling""" shots = 2000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=False) targets = ref_measure.measure_counts_nondeterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots) result = self.SIMULATOR.run( qobj, backend_options=self.BACKEND_OPTS).result() self.is_completed(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots) # Test sampling was disabled for res in result.results: self.assertIn("measure_sampling", res.metadata) self.assertEqual(res.metadata["measure_sampling"], False)
def test_measure_nondeterministic_with_sampling(self): """Test QasmSimulator measure with non-deterministic counts with sampling""" shots = 4000 circuits = ref_measure.measure_circuits_nondeterministic( allow_sampling=True) targets = ref_measure.measure_counts_nondeterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots) result = self.SIMULATOR.run( qobj, **self.BACKEND_OPTS).result() self.assertSuccess(result) self.compare_counts(result, circuits, targets, delta=0.05 * shots) # Test sampling was enabled for res in result.results: self.assertIn("measure_sampling", res.metadata) self.assertEqual(res.metadata["measure_sampling"], True)