|
1 | 1 | # Circuit Representation |
2 | 2 |
|
| 3 | +<!--skip: Circuit examples require Guppy and specific circuit APIs--> |
| 4 | + |
3 | 5 | PECOS provides several ways to represent and work with quantum circuits, from high-level program formats to low-level data structures. |
4 | 6 |
|
5 | 7 | ## Quick Guide: What Should I Use? |
@@ -29,7 +31,7 @@ When using PECOS's `sim()` API, you wrap your program in one of these types: |
29 | 31 | ### Example: Different Program Types |
30 | 32 |
|
31 | 33 | === ":fontawesome-brands-python: Python" |
32 | | - ```python |
| 34 | + ```python,skip |
33 | 35 | from pecos import sim, Guppy, Qasm, Hugr |
34 | 36 |
|
35 | 37 | # Guppy - recommended for new code |
@@ -110,7 +112,7 @@ A directed acyclic graph representation where nodes are gates and edges are qubi |
110 | 112 | ### Quick Start |
111 | 113 |
|
112 | 114 | === ":fontawesome-brands-python: Python" |
113 | | - ```python |
| 115 | + ```python,skip |
114 | 116 | from pecos.quantum import DagCircuit |
115 | 117 |
|
116 | 118 | # Fluent builder API |
@@ -142,7 +144,7 @@ A directed acyclic graph representation where nodes are gates and edges are qubi |
142 | 144 | The fluent API automatically wires gates on the same qubit: |
143 | 145 |
|
144 | 146 | === ":fontawesome-brands-python: Python" |
145 | | - ```python |
| 147 | + ```python,skip |
146 | 148 | from pecos.quantum import DagCircuit |
147 | 149 |
|
148 | 150 | circuit = DagCircuit() |
@@ -214,7 +216,7 @@ The fluent API automatically wires gates on the same qubit: |
214 | 216 | Gates can have arbitrary metadata attached: |
215 | 217 |
|
216 | 218 | === ":fontawesome-brands-python: Python" |
217 | | - ```python |
| 219 | + ```python,skip |
218 | 220 | from pecos.quantum import DagCircuit, Attribute |
219 | 221 |
|
220 | 222 | circuit = DagCircuit() |
@@ -248,7 +250,7 @@ Gates can have arbitrary metadata attached: |
248 | 250 | ### Circuit Analysis |
249 | 251 |
|
250 | 252 | === ":fontawesome-brands-python: Python" |
251 | | - ```python |
| 253 | + ```python,skip |
252 | 254 | circuit = DagCircuit() |
253 | 255 | circuit.h(0).cx(0, 1).h(1).cx(1, 2).mz(0).mz(1).mz(2) |
254 | 256 |
|
@@ -305,7 +307,7 @@ Gates can have arbitrary metadata attached: |
305 | 307 | For advanced use cases, you can manually add gates and wire them: |
306 | 308 |
|
307 | 309 | === ":fontawesome-brands-python: Python" |
308 | | - ```python |
| 310 | + ```python,skip |
309 | 311 | from pecos.quantum import DagCircuit, Gate, QubitId |
310 | 312 |
|
311 | 313 | circuit = DagCircuit() |
@@ -348,7 +350,7 @@ A time-sliced circuit representation where gates are organized into discrete tim |
348 | 350 | ### Quick Start |
349 | 351 |
|
350 | 352 | === ":fontawesome-brands-python: Python" |
351 | | - ```python |
| 353 | + ```python,skip |
352 | 354 | from pecos.quantum import TickCircuit |
353 | 355 |
|
354 | 356 | circuit = TickCircuit() |
@@ -390,7 +392,7 @@ A time-sliced circuit representation where gates are organized into discrete tim |
390 | 392 | TickCircuit prevents scheduling conflicting gates in the same tick: |
391 | 393 |
|
392 | 394 | === ":fontawesome-brands-python: Python" |
393 | | - ```python |
| 395 | + ```python,skip |
394 | 396 | from pecos.quantum import TickCircuit |
395 | 397 |
|
396 | 398 | circuit = TickCircuit() |
@@ -420,7 +422,7 @@ TickCircuit prevents scheduling conflicting gates in the same tick: |
420 | 422 | ### Tick Metadata |
421 | 423 |
|
422 | 424 | === ":fontawesome-brands-python: Python" |
423 | | - ```python |
| 425 | + ```python,skip |
424 | 426 | circuit = TickCircuit() |
425 | 427 |
|
426 | 428 | # Add metadata to a tick |
@@ -450,7 +452,7 @@ TickCircuit prevents scheduling conflicting gates in the same tick: |
450 | 452 | TickCircuit can be converted to and from DagCircuit: |
451 | 453 |
|
452 | 454 | === ":fontawesome-brands-python: Python" |
453 | | - ```python |
| 455 | + ```python,skip |
454 | 456 | from pecos.quantum import DagCircuit, TickCircuit |
455 | 457 |
|
456 | 458 | # TickCircuit -> DagCircuit |
@@ -488,7 +490,7 @@ For general graph algorithms beyond quantum circuits, PECOS provides `DiGraph` ( |
488 | 490 | A general directed graph with weighted edges and attributes: |
489 | 491 |
|
490 | 492 | === ":fontawesome-brands-python: Python" |
491 | | - ```python |
| 493 | + ```python,skip |
492 | 494 | from pecos.graph import DiGraph |
493 | 495 |
|
494 | 496 | graph = DiGraph() |
@@ -538,7 +540,7 @@ A general directed graph with weighted edges and attributes: |
538 | 540 | A directed acyclic graph with topological ordering and cycle prevention: |
539 | 541 |
|
540 | 542 | === ":fontawesome-brands-python: Python" |
541 | | - ```python |
| 543 | + ```python,skip |
542 | 544 | from pecos.graph import DAG |
543 | 545 |
|
544 | 546 | dag = DAG() |
|
0 commit comments