def test_measure_deterministic_without_sampling(self): """Test QasmSimulator measure with deterministic counts without sampling""" shots = 100 circuits = ref_measure.measure_circuits_deterministic( allow_sampling=False) target_counts = ref_measure.measure_counts_deterministic(shots) target_memory = ref_measure.measure_memory_deterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots, memory=True) result = self.SIMULATOR.run(qobj, **self.BACKEND_OPTS).result() self.assertSuccess(result) self.compare_counts(result, circuits, target_counts, delta=0) self.compare_memory(result, circuits, target_memory)
def test_measure_deterministic_with_sampling(self): """Test QasmSimulator measure with deterministic counts with sampling""" shots = 100 circuits = ref_measure.measure_circuits_deterministic( allow_sampling=True) target_counts = ref_measure.measure_counts_deterministic(shots) target_memory = ref_measure.measure_memory_deterministic(shots) qobj = assemble(circuits, self.SIMULATOR, shots=shots, memory=True) result = self.SIMULATOR.run( qobj, backend_options=self.BACKEND_OPTS).result() self.assertTrue(getattr(result, 'success', False)) self.compare_counts(result, circuits, target_counts, delta=0) self.compare_memory(result, circuits, target_memory) self.compare_result_metadata(result, circuits, "measure_sampling", True)
def test_measure_deterministic_without_sampling(self, method, device): """Test AerSimulator measure with deterministic counts without sampling""" backend = self.backend(method=method, device=device) shots = 100 circuits = ref_measure.measure_circuits_deterministic( allow_sampling=False) target_counts = ref_measure.measure_counts_deterministic(shots) target_memory = ref_measure.measure_memory_deterministic(shots) result = backend.run(circuits, memory=True, shots=shots).result() self.assertSuccess(result) self.compare_counts(result, circuits, target_counts, delta=0) self.compare_memory(result, circuits, target_memory) self.compare_result_metadata(result, circuits, "measure_sampling", False)