def test_conditional_gate_1bit(self): """Test conditional gates on 1-bit conditional register.""" circuits = ref_conditionals.conditional_circuits_1bit(final_measure=False) targets = ref_conditionals.conditional_statevector_1bit() job = execute(circuits, StatevectorSimulator(), shots=1) result = job.result() self.assertTrue(getattr(result, 'success', False)) self.compare_statevector(result, circuits, targets)
def test_conditional_1bit(self): """Test conditional operations on 1-bit conditional register.""" circuits = ref_conditionals.conditional_circuits_1bit(final_measure=False) targets = ref_conditionals.conditional_statevector_1bit() job = execute(circuits, StatevectorSimulator(), shots=1) result = job.result() self.is_completed(result) self.compare_statevector(result, circuits, targets)
def test_conditional_unitary_1bit(self): """Test conditional unitaries on 1-bit conditional register.""" circuits = ref_conditionals.conditional_circuits_1bit( final_measure=False, conditional_type='unitary') targets = ref_conditionals.conditional_statevector_1bit() job = execute(circuits, self.SIMULATOR, shots=1, **self.BACKEND_OPTS) result = job.result() self.assertSuccess(result) self.compare_statevector(result, circuits, targets)
def test_conditional_unitary_1bit(self, device): """Test conditional unitaries on 1-bit conditional register.""" backend = self.backend(device=device) circuits = ref_conditionals.conditional_circuits_1bit( final_measure=False, conditional_type='unitary') circuits = transpile(circuits, backend, optimization_level=1) result = backend.run(circuits, shots=1).result() targets = ref_conditionals.conditional_statevector_1bit() self.assertSuccess(result) self.compare_statevector(result, circuits, targets)