File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed
Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change 22import textwrap
33
44import cirq
5- import cirq .contrib
65import cirq .testing
76import cirq .contrib .qasm_import as qasm_import
87import cirq .circuits .qasm_output as qasm_output
@@ -86,6 +85,18 @@ def generator(n_tests: int):
8685 """
8786 )
8887
88+ yield textwrap .dedent (
89+ """
90+ OPENQASM 2.0;
91+ include "qelib1.inc";
92+
93+ qreg q[2];
94+
95+ cu3(0.0, 0.6, 3.141591) q[0],q[1];
96+
97+ """
98+ )
99+
89100 rgen = np .random .RandomState (128 )
90101 for num in range (n_tests ):
91102 # Generate a new instance:
@@ -117,3 +128,28 @@ def kernel():
117128 cirq .testing .assert_allclose_up_to_global_phase (
118129 cirq .unitary (old_circuit ), cirq .unitary (cirq_circuit ), atol = 1e-8
119130 )
131+
132+
133+ def test_cu3_rewrite ():
134+ prog = textwrap .dedent (
135+ """
136+ OPENQASM 2.0;
137+ include "qelib1.inc";
138+
139+ qreg q[2];
140+
141+ cu3(0.0, 0.6, 3.141591) q[0],q[1];
142+
143+ """
144+ )
145+
146+ @qasm2 .main .add (qasm2 .dialects .inline )
147+ def kernel ():
148+ qasm2 .inline (prog )
149+
150+ walk .Walk (RydbergGateSetRewriteRule (kernel .dialects )).rewrite (kernel .code )
151+
152+ new_qasm2 = qasm2 .emit .QASM2 ().emit_str (kernel )
153+
154+ # simple-stupid test to see if the rewrite injected a bunch of new lines
155+ assert new_qasm2 .count ("\n " ) > prog .count ("\n " )
You can’t perform that action at this time.
0 commit comments