Skip to content

Commit 44457f7

Browse files
committed
more tests for custom gates
1 parent 0072f91 commit 44457f7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/python/circuit/test_commutation_checker.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,21 @@ def test_rotation_mod_2pi(self, gate_cls):
453453
scc.commute(generic_gate, [0], [], gate, list(range(gate.num_qubits)), [])
454454
)
455455

456+
def test_custom_gate(self):
457+
"""Test a custom gate."""
458+
my_cx = NewGateCX()
459+
460+
self.assertTrue(scc.commute(my_cx, [0, 1], [], XGate(), [1], []))
461+
self.assertFalse(scc.commute(my_cx, [0, 1], [], XGate(), [0], []))
462+
self.assertTrue(scc.commute(my_cx, [0, 1], [], ZGate(), [0], []))
463+
464+
self.assertFalse(scc.commute(my_cx, [0, 1], [], my_cx, [1, 0], []))
465+
self.assertTrue(scc.commute(my_cx, [0, 1], [], my_cx, [0, 1], []))
466+
456467
def test_custom_gate_caching(self):
457468
"""Test a custom gate is correctly handled on consecutive runs."""
458469

459-
all_commuter = MyEvilRXGate(0) # this will with anything
470+
all_commuter = MyEvilRXGate(0) # this will commute with anything
460471
some_rx = MyEvilRXGate(1.6192) # this should not commute with H
461472

462473
# the order here is important: we're testing whether the gate that commutes with

0 commit comments

Comments
 (0)