@@ -34,6 +34,30 @@ def test_eq():
3434 eq .add_equality_group (cirq .PhasedXZGate (x_exponent = 1 , z_exponent = 0 , axis_phase_exponent = 0 ))
3535
3636
37+ @pytest .mark .parametrize ('z0_rad' , [- np .pi / 5 , 0 , np .pi / 5 , np .pi / 4 , np .pi / 2 , np .pi ])
38+ @pytest .mark .parametrize ('y_rad' , [0 , np .pi / 5 , np .pi / 4 , np .pi / 2 , np .pi ])
39+ @pytest .mark .parametrize ('z1_rad' , [- np .pi / 5 , 0 , np .pi / 5 , np .pi / 4 , np .pi / 2 , np .pi ])
40+ def test_from_zyz_angles (z0_rad : float , y_rad : float , z1_rad : float ) -> None :
41+ q = cirq .q (0 )
42+ phxz = cirq .PhasedXZGate .from_zyz_angles (z0_rad , y_rad , z1_rad )
43+ zyz = cirq .Circuit (cirq .rz (z0_rad ).on (q ), cirq .ry (y_rad ).on (q ), cirq .rz (z1_rad ).on (q ))
44+ cirq .testing .assert_allclose_up_to_global_phase (
45+ cirq .unitary (phxz ), cirq .unitary (zyz ), atol = 1e-8
46+ )
47+
48+
49+ @pytest .mark .parametrize ('z0' , [- 0.2 , 0 , 0.2 , 0.25 , 0.5 , 1 ])
50+ @pytest .mark .parametrize ('y' , [0 , 0.2 , 0.25 , 0.5 , 1 ])
51+ @pytest .mark .parametrize ('z1' , [- 0.2 , 0 , 0.2 , 0.25 , 0.5 , 1 ])
52+ def test_from_zyz_exponents (z0 : float , y : float , z1 : float ) -> None :
53+ q = cirq .q (0 )
54+ phxz = cirq .PhasedXZGate .from_zyz_exponents (z0 , y , z1 )
55+ zyz = cirq .Circuit (cirq .Z (q ) ** z0 , cirq .Y (q ) ** y , cirq .Z (q ) ** z1 )
56+ cirq .testing .assert_allclose_up_to_global_phase (
57+ cirq .unitary (phxz ), cirq .unitary (zyz ), atol = 1e-8
58+ )
59+
60+
3761def test_canonicalization ():
3862 def f (x , z , a ):
3963 return cirq .PhasedXZGate (x_exponent = x , z_exponent = z , axis_phase_exponent = a )
0 commit comments