@@ -166,9 +166,6 @@ def test_libqasm_error(self):
166
166
use_libqasm = True ,
167
167
)
168
168
169
- @unittest .skipIf (
170
- importlib .util .find_spec ("quantify_scheduler" ) is None , reason = "quantify_scheduler is not installed"
171
- )
172
169
def test_export_quantify_scheduler (self ):
173
170
myCircuit = Circuit .from_string (
174
171
"""
@@ -177,12 +174,16 @@ def test_export_quantify_scheduler(self):
177
174
qubit[3] qreg
178
175
179
176
h qreg[1]
177
+ cz qreg[0], qreg[1]
178
+ cnot qreg[0], qreg[1]
180
179
crk qreg[0], qreg[1], 4
181
180
h qreg[0]
182
181
"""
183
182
)
184
183
185
184
myCircuit .decompose (decomposer = CNOTDecomposer )
185
+
186
+ # Quantify-scheduler prefers CZ.
186
187
myCircuit .replace (
187
188
cnot ,
188
189
lambda control , target : [
@@ -191,34 +192,50 @@ def test_export_quantify_scheduler(self):
191
192
h (target ),
192
193
],
193
194
)
194
- myCircuit .merge_single_qubit_gates ()
195
- myCircuit .decompose (decomposer = ZYZDecomposer ) # FIXME: for best gate count we need a Z-XY decomposer.
196
-
197
- exported_schedule = myCircuit .export (format = ExportFormat .QUANTIFY_SCHEDULER )
198
-
199
- self .assertEqual (exported_schedule .name , "Exported OpenSquirrel circuit" )
200
195
201
- operation_ids = [ v [ "operation_id" ] for k , v in exported_schedule . schedulables . items ()]
202
- operations = [ exported_schedule . operations [ operation_id ]. name for operation_id in operation_ids ]
196
+ # Reduce gate count by single-qubit gate fusion.
197
+ myCircuit . merge_single_qubit_gates ()
203
198
204
- self .assertEqual (
205
- operations ,
206
- [
207
- "Rz(1.5707963, 'qreg[1]')" ,
208
- "Rxy(0.19634954, 1.5707963, 'qreg[1]')" ,
209
- "Rz(-1.5707963, 'qreg[1]')" ,
210
- "CZ (qreg[0], qreg[1])" ,
211
- "Rz(1.5707963, 'qreg[1]')" ,
212
- "Rxy(-0.19634954, 1.5707963, 'qreg[1]')" ,
213
- "Rz(-1.5707963, 'qreg[1]')" ,
214
- "CZ (qreg[0], qreg[1])" ,
215
- "Rz(0.19634954, 'qreg[0]')" ,
216
- "Rxy(-1.5707963, 1.5707963, 'qreg[0]')" ,
217
- "Rz(3.1415927, 'qreg[0]')" ,
218
- "Rz(3.1415927, 'qreg[1]')" ,
219
- "Rxy(1.5707963, 1.5707963, 'qreg[1]')" ,
220
- ],
221
- )
199
+ # FIXME: for best gate count we need a Z-XY decomposer.
200
+ # See https://github.com/QuTech-Delft/OpenSquirrel/issues/98
201
+ myCircuit .decompose (decomposer = ZYZDecomposer )
202
+
203
+ if importlib .util .find_spec ("quantify_scheduler" ) is None :
204
+ with self .assertRaisesRegex (
205
+ Exception , "quantify-scheduler is not installed, or cannot be installed on " "your system"
206
+ ):
207
+ myCircuit .export (format = ExportFormat .QUANTIFY_SCHEDULER )
208
+ else :
209
+ exported_schedule = myCircuit .export (format = ExportFormat .QUANTIFY_SCHEDULER )
210
+
211
+ self .assertEqual (exported_schedule .name , "Exported OpenSquirrel circuit" )
212
+
213
+ operations = [exported_schedule .operations [schedulable ["operation_id" ]].name for schedulable in exported_schedule .schedulables .values ()]
214
+
215
+ self .assertEqual (
216
+ operations ,
217
+ [
218
+ "Rz(3.1415927, 'qreg[1]')" ,
219
+ "Rxy(1.5707963, 1.5707963, 'qreg[1]')" ,
220
+ "CZ (qreg[0], qreg[1])" ,
221
+ "Rz(3.1415927, 'qreg[1]')" ,
222
+ "Rxy(1.5707963, 1.5707963, 'qreg[1]')" ,
223
+ "CZ (qreg[0], qreg[1])" ,
224
+ "Rz(1.5707963, 'qreg[1]')" ,
225
+ "Rxy(0.19634954, 1.5707963, 'qreg[1]')" ,
226
+ "Rz(-1.5707963, 'qreg[1]')" ,
227
+ "CZ (qreg[0], qreg[1])" ,
228
+ "Rz(1.5707963, 'qreg[1]')" ,
229
+ "Rxy(-0.19634954, 1.5707963, 'qreg[1]')" ,
230
+ "Rz(-1.5707963, 'qreg[1]')" ,
231
+ "CZ (qreg[0], qreg[1])" ,
232
+ "Rz(0.19634954, 'qreg[0]')" ,
233
+ "Rxy(-1.5707963, 1.5707963, 'qreg[0]')" ,
234
+ "Rz(3.1415927, 'qreg[0]')" ,
235
+ "Rz(3.1415927, 'qreg[1]')" ,
236
+ "Rxy(1.5707963, 1.5707963, 'qreg[1]')" ,
237
+ ],
238
+ )
222
239
223
240
224
241
if __name__ == "__main__" :
0 commit comments