|
17 | 17 |
|
18 | 18 | import ddt
|
19 | 19 |
|
20 |
| -from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit |
21 |
| -from qiskit.circuit import Parameter |
| 20 | +from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit, pulse |
| 21 | +from qiskit.circuit import Parameter, Gate |
22 | 22 | from qiskit.circuit.library import CXGate, CZGate, ECRGate, RXXGate, RYYGate, RZXGate, RZZGate
|
23 | 23 | from qiskit.compiler import transpile
|
24 | 24 | from qiskit.transpiler import TranspilerError, CouplingMap, Target
|
@@ -430,6 +430,33 @@ def test_target_control_flow(self):
|
430 | 430 | pass_ = GateDirection(None, target)
|
431 | 431 | self.assertEqual(pass_(circuit), expected)
|
432 | 432 |
|
| 433 | + def test_allows_calibrated_gates_coupling_map(self): |
| 434 | + """Test that the gate direction pass allows a gate that's got a calibration to pass through |
| 435 | + without error.""" |
| 436 | + cm = CouplingMap([(1, 0)]) |
| 437 | + |
| 438 | + gate = Gate("my_2q_gate", 2, []) |
| 439 | + circuit = QuantumCircuit(2) |
| 440 | + circuit.append(gate, (0, 1)) |
| 441 | + circuit.add_calibration(gate, (0, 1), pulse.ScheduleBlock()) |
| 442 | + |
| 443 | + pass_ = GateDirection(cm) |
| 444 | + self.assertEqual(pass_(circuit), circuit) |
| 445 | + |
| 446 | + def test_allows_calibrated_gates_target(self): |
| 447 | + """Test that the gate direction pass allows a gate that's got a calibration to pass through |
| 448 | + without error.""" |
| 449 | + target = Target(num_qubits=2) |
| 450 | + target.add_instruction(CXGate(), properties={(0, 1): None}) |
| 451 | + |
| 452 | + gate = Gate("my_2q_gate", 2, []) |
| 453 | + circuit = QuantumCircuit(2) |
| 454 | + circuit.append(gate, (0, 1)) |
| 455 | + circuit.add_calibration(gate, (0, 1), pulse.ScheduleBlock()) |
| 456 | + |
| 457 | + pass_ = GateDirection(None, target) |
| 458 | + self.assertEqual(pass_(circuit), circuit) |
| 459 | + |
433 | 460 |
|
434 | 461 | if __name__ == "__main__":
|
435 | 462 | unittest.main()
|
0 commit comments