Commit 70fa389
committed
Fix control flow panics in PyDAGCircuit
Replace .unwrap() calls in pack_into and unpack_into methods with proper
error handling to prevent panics when converting circuits with control flow
operations to DAGs.
This fixes the TODO mentioned in PR Qiskit#15301 about test failures/panics with
control flow (circuit to dag issues).
Changes:
- Replace .unwrap() on qubits.find() with ok_or_else() returning DAGCircuitError
- Replace .unwrap() on clbits.find() with ok_or_else() returning DAGCircuitError
- Replace .unwrap() on vars.find() with ok_or_else() returning DAGCircuitError
- Replace .unwrap() on qubits.get() with ok_or_else() returning DAGCircuitError
- Replace .unwrap() on clbits.get() with ok_or_else() returning DAGCircuitError
- Replace .unwrap() on vars.get() with ok_or_else() returning DAGCircuitError
All control flow tests now pass successfully.1 parent 456d2d9 commit 70fa389
1 file changed
+102
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
198 | 208 | | |
199 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
200 | 220 | | |
201 | 221 | | |
202 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
203 | 233 | | |
204 | 234 | | |
205 | 235 | | |
206 | 236 | | |
207 | 237 | | |
208 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
209 | 249 | | |
210 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
211 | 261 | | |
212 | 262 | | |
213 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
214 | 274 | | |
215 | 275 | | |
216 | 276 | | |
| |||
264 | 324 | | |
265 | 325 | | |
266 | 326 | | |
267 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
268 | 333 | | |
269 | 334 | | |
270 | 335 | | |
| |||
276 | 341 | | |
277 | 342 | | |
278 | 343 | | |
279 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
280 | 350 | | |
281 | 351 | | |
282 | 352 | | |
| |||
288 | 358 | | |
289 | 359 | | |
290 | 360 | | |
291 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
292 | 367 | | |
293 | 368 | | |
294 | 369 | | |
| |||
300 | 375 | | |
301 | 376 | | |
302 | 377 | | |
303 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
304 | 384 | | |
305 | 385 | | |
306 | 386 | | |
| |||
342 | 422 | | |
343 | 423 | | |
344 | 424 | | |
345 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
346 | 431 | | |
347 | 432 | | |
348 | 433 | | |
| |||
355 | 440 | | |
356 | 441 | | |
357 | 442 | | |
358 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
359 | 449 | | |
360 | 450 | | |
361 | 451 | | |
| |||
0 commit comments