Skip to content

Commit 59002d8

Browse files
authored
Add test to cover parameterized gates w/ 2 targets (#250)
- Add test to cover parameterized gates with two targets handed to the simulator via Qiskit
1 parent fbfe86a commit 59002d8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/python/simulator/test_qasm_simulator.py

+43
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,46 @@ def test_qasm_simulator_approximation(self):
103103
).result()
104104
counts = result.get_counts()
105105
assert len(counts) == 1
106+
107+
def test_qasm_simulator_portfolioqaoa(self):
108+
"""Run simulator with with 2-target gates that take a parameter. Circuit taken from MQT Bench."""
109+
circuit = QuantumCircuit.from_qasm_str(
110+
"""OPENQASM 2.0;
111+
include "qelib1.inc";
112+
qreg q[3];
113+
creg meas[3];
114+
creg meas0[3];
115+
u2(0.41951949,-pi) q[0];
116+
u2(0.41620669,-pi) q[1];
117+
rzz(-0.420917333908502) q[0],q[1];
118+
u2(0.41905329,-pi) q[2];
119+
rzz(-0.421016123405307) q[0],q[2];
120+
u3(2.2348228,1.2558831,-pi/2) q[0];
121+
rzz(-0.420940441831552) q[1],q[2];
122+
u3(2.2348228,1.2087537,-pi/2) q[1];
123+
rzz(-5.98815838177421) q[0],q[1];
124+
u3(2.2348228,1.2492507,-pi/2) q[2];
125+
rzz(-5.98956380537088) q[0],q[2];
126+
u3(0.56042125,-1.2358007,pi/2) q[0];
127+
rzz(-5.98848712542991) q[1],q[2];
128+
u3(0.56042125,-1.2880621,pi/2) q[1];
129+
rzz(-6.64023274758061) q[0],q[1];
130+
u3(0.56042125,-1.2431553,pi/2) q[2];
131+
rzz(-6.6417912133385) q[0],q[2];
132+
rx(-4.06512402388918) q[0];
133+
rzz(-6.64059728943955) q[1],q[2];
134+
rx(-4.06512402388918) q[1];
135+
rx(-4.06512402388918) q[2];
136+
barrier q[0],q[1],q[2];
137+
measure q[0] -> meas[0];
138+
measure q[1] -> meas[1];
139+
measure q[2] -> meas[2];
140+
barrier q[0],q[1],q[2];
141+
measure q[0] -> meas0[0];
142+
measure q[1] -> meas0[1];
143+
measure q[2] -> meas0[2];
144+
"""
145+
)
146+
result = execute(circuit, self.backend).result()
147+
counts = result.get_counts()
148+
assert len(counts) == 8

0 commit comments

Comments
 (0)