@@ -453,10 +453,21 @@ def test_rotation_mod_2pi(self, gate_cls):
453
453
scc .commute (generic_gate , [0 ], [], gate , list (range (gate .num_qubits )), [])
454
454
)
455
455
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
+
456
467
def test_custom_gate_caching (self ):
457
468
"""Test a custom gate is correctly handled on consecutive runs."""
458
469
459
- all_commuter = MyEvilRXGate (0 ) # this will with anything
470
+ all_commuter = MyEvilRXGate (0 ) # this will commute with anything
460
471
some_rx = MyEvilRXGate (1.6192 ) # this should not commute with H
461
472
462
473
# the order here is important: we're testing whether the gate that commutes with
0 commit comments