draw
eigenkit.core.draw
Text drawer for CircuitSpec, which does not depend on the provider.
It draws the circuit as a string of several lines:
A single-qubit gate is drawn as a NAME(param) label on its wire. A
controlled-NOT (CNOT) gate is drawn as ● on the control and X on the target,
with │ connectors between the wires that it spans.
Parameter expressions are drawn as symbols:
Constant(0.5) -> "0.5"
WeightRef(3) -> "w_3"
InputRef(0) -> "x_0"
Scale(InputRef(0), 2*pi) -> "6.28*x_0"
Negate(WeightRef(0)) -> "-w_0"
Sum((w_0, x_0)) -> "w_0+x_0"
Multiply(w_0, x_0) -> "w_0*x_0"
draw_text(spec, *, decimals=3)
Draw spec as text on several lines.
The text is made of American Standard Code for Information Interchange (ASCII) characters and a few box-drawing characters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
CircuitSpec
|
The |
required |
decimals
|
int
|
The number of significant digits of constant angles. Default:
|
3
|
Returns:
| Type | Description |
|---|---|
str
|
The drawing, as a string. Print it to see the circuit. |