def test_teleport_default_basis_gates(self):
     """Test teleport circuits compiling to backend default basis_gates."""
     shots = 1000
     circuits = ref_algorithms.teleport_circuit()
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_algorithms.teleport_counts(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_deterministic_without_sampling(self):
     """Test ExtendedStabilizer measure with deterministic counts without sampling"""
     shots = 100
     circuits = ref_measure.measure_circuits_deterministic(
         allow_sampling=False)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_measure.measure_counts_deterministic(shots)
     job = QasmSimulator().run(qobj, **self.BACKEND_OPTS)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0)
 def test_t_gate_deterministic_default_basis_gates(self):
     """Test t-gate circuits compiling to backend default basis_gates."""
     shots = 100
     circuits = ref_non_clifford.t_gate_circuits_deterministic(
         final_measure=True)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_non_clifford.t_gate_counts_deterministic(shots)
     job = QasmSimulator().run(qobj, **self.BACKEND_OPTS)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0.1 * shots)
 def test_sdg_gate_nondeterministic_default_basis_gates(self):
     shots = 4000
     """Test sdg-gate circuits compiling to backend default basis_gates."""
     circuits = ref_1q_clifford.sdg_gate_circuits_nondeterministic(
         final_measure=True)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_1q_clifford.sdg_gate_counts_nondeterministic(shots)
     job = QasmSimulator().run(qobj, **self.BACKEND_OPTS_SAMPLING)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0.05 * shots)
 def test_conditional_2bit(self):
     """Test conditional operations on 2-bit conditional register."""
     shots = 100
     circuits = ref_conditionals.conditional_circuits_2bit(
         final_measure=True)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_conditionals.conditional_counts_2bit(shots)
     job = QasmSimulator().run(qobj, **self.BACKEND_OPTS_SAMPLING)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0)
 def test_measure_nondeterministic_multi_qubit_without_sampling(self):
     """Test CHimulator reset with non-deterministic counts"""
     shots = 4000
     circuits = ref_measure.multiqubit_measure_circuits_nondeterministic(
         allow_sampling=False)
     targets = ref_measure.multiqubit_measure_counts_nondeterministic(shots)
     qobj = assemble(circuits, QasmSimulator(), shots=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, **self.BACKEND_OPTS_SAMPLING)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0.05 * shots)
 def test_reset_deterministic(self):
     """Test ExtendedStabilizer reset with for circuits with deterministic counts"""
     # For statevector output we can combine deterministic and non-deterministic
     # count output circuits
     shots = 100
     circuits = ref_reset.reset_circuits_deterministic(final_measure=True)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_reset.reset_counts_deterministic(shots)
     job = QasmSimulator().run(qobj, **self.BACKEND_OPTS)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0)
 def test_grovers_default_basis_gates(self):
     """Test grovers circuits compiling to backend default basis_gates."""
     shots = 500
     circuits = ref_algorithms.grovers_circuit(final_measure=True,
                                               allow_sampling=True)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_algorithms.grovers_counts(shots)
     opts = self.BACKEND_OPTS.copy()
     opts["extended_stabilizer_mixing_time"] = 100
     job = QasmSimulator().run(qobj, **opts)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0.1 * shots)
 def test_ccx_gate_nondeterministic_default_basis_gates(self):
     """Test ccx-gate circuits compiling to backend default basis_gates."""
     shots = 500
     circuits = ref_non_clifford.ccx_gate_circuits_nondeterministic(
         final_measure=True)
     qobj = assemble(circuits, QasmSimulator(), shots=shots)
     targets = ref_non_clifford.ccx_gate_counts_nondeterministic(shots)
     opts = self.BACKEND_OPTS.copy()
     opts["extended_stabilizer_mixing_time"] = 100
     job = QasmSimulator().run(qobj, **opts)
     result = job.result()
     self.assertSuccess(result)
     self.compare_counts(result, circuits, targets, delta=0.10 * shots)