Commit b35999e
Add custom operation conversion hook to cirq_optree_to_cbloq (#1834)
Adds a backward-compatible hook that lets callers provide a custom
Operation -> Bloq conversion function. This is needed by the FLASQ
library to perform custom analysis as we convert cirq optrees to bloqs.
For example, calculating the Manhattan distance between the two qubits
involved in a two-qubit gate.
The new parameter defaults to None, so all existing callers are
unaffected. When provided, it replaces the default extraction logic for
each operation in the circuit.
All existing cirq_interop tests pass unchanged and a new test was added
for this new functionality.
Co-authored-by: Matthew Harrigan <mpharrigan@google.com>1 parent 5ba42c1 commit b35999e
File tree
2 files changed
+59
-3
lines changed- qualtran/cirq_interop
2 files changed
+59
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
319 | 330 | | |
320 | 331 | | |
321 | 332 | | |
322 | | - | |
| 333 | + | |
323 | 334 | | |
324 | 335 | | |
325 | 336 | | |
| |||
465 | 476 | | |
466 | 477 | | |
467 | 478 | | |
| 479 | + | |
468 | 480 | | |
469 | 481 | | |
470 | 482 | | |
| |||
495 | 507 | | |
496 | 508 | | |
497 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
498 | 521 | | |
499 | 522 | | |
500 | 523 | | |
| |||
533 | 556 | | |
534 | 557 | | |
535 | 558 | | |
536 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
537 | 563 | | |
538 | 564 | | |
539 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
0 commit comments