@@ -683,33 +683,34 @@ def to_phased_xz_gate(self) -> phased_x_z_gate.PhasedXZGate:
683
683
flip_index = int (z_to_flip ) * 2 + x_to_flip
684
684
a , x , z = 0.0 , 0.0 , 0.0
685
685
686
- if np .array_equal (self .clifford_tableau .matrix (), [[1 , 0 ], [0 , 1 ]]):
686
+ matrix = self .clifford_tableau .matrix ()
687
+ if np .array_equal (matrix , [[1 , 0 ], [0 , 1 ]]):
687
688
# I, Z, X, Y cases
688
689
to_phased_xz = [(0.0 , 0.0 , 0.0 ), (0.0 , 0.0 , 1.0 ), (0.0 , 1.0 , 0.0 ), (0.5 , 1.0 , 0.0 )]
689
690
a , x , z = to_phased_xz [flip_index ]
690
- elif np .array_equal (self . clifford_tableau . matrix () , [[1 , 0 ], [1 , 1 ]]):
691
+ elif np .array_equal (matrix , [[1 , 0 ], [1 , 1 ]]):
691
692
# +/- X_sqrt, 2 Hadamard-like gates acting on the YZ plane
692
693
a = 0.0
693
694
x = 0.5 if x_to_flip ^ z_to_flip else - 0.5
694
695
z = 1.0 if x_to_flip else 0.0
695
- elif np .array_equal (self . clifford_tableau . matrix () , [[0 , 1 ], [1 , 0 ]]):
696
+ elif np .array_equal (matrix , [[0 , 1 ], [1 , 0 ]]):
696
697
# +/- Y_sqrt, 2 Hadamard-like gates acting on the XZ plane
697
698
a = 0.5
698
699
x = 0.5 if x_to_flip else - 0.5
699
700
z = 0.0 if x_to_flip ^ z_to_flip else 1.0
700
- elif np .array_equal (self . clifford_tableau . matrix () , [[1 , 1 ], [0 , 1 ]]):
701
+ elif np .array_equal (matrix , [[1 , 1 ], [0 , 1 ]]):
701
702
# +/- Z_sqrt, 2 Hadamard-like gates acting on the XY plane
702
703
to_phased_xz = [(0.0 , 0.0 , 0.5 ), (0.0 , 0.0 , - 0.5 ), (0.25 , 1.0 , 0.0 ), (- 0.25 , 1.0 , 0.0 )]
703
704
a , x , z = to_phased_xz [flip_index ]
704
- elif np .array_equal (self . clifford_tableau . matrix () , [[0 , 1 ], [1 , 1 ]]):
705
+ elif np .array_equal (matrix , [[0 , 1 ], [1 , 1 ]]):
705
706
# axis swapping rotation -- (312) permutation
706
707
a = 0.5
707
708
x = 0.5 if x_to_flip else - 0.5
708
709
z = 0.5 if x_to_flip ^ z_to_flip else - 0.5
709
710
else :
710
711
# axis swapping rotation -- (231) permutation.
711
712
# This should be the only cases left.
712
- assert np .array_equal (self . clifford_tableau . matrix () , [[1 , 1 ], [1 , 0 ]])
713
+ assert np .array_equal (matrix , [[1 , 1 ], [1 , 0 ]])
713
714
a = 0.0
714
715
x = - 0.5 if x_to_flip ^ z_to_flip else 0.5
715
716
z = - 0.5 if x_to_flip else 0.5
0 commit comments