Enums — GateType, OpType, PIC_TYPE
API reference for core enumerations in pyqpanda3.
GateType
Enumeration of all quantum gate types. Used by QGate.gate_type(), noise model configuration, and transpilation.
Values
| Value | Description |
|---|---|
GATE_NOP | No operation (identity placeholder) |
GATE_UNDEFINED | Undefined gate type |
I | Identity gate |
X | Pauli-X (NOT) gate |
Y | Pauli-Y gate |
Z | Pauli-Z gate |
X1 | SX gate ( |
Y1 | Y1 gate ( |
Z1 | Z1 gate ( |
H | Hadamard gate |
T | T gate ( |
S | S gate (phase gate) |
P | Parameterized phase gate |
RX | Rotation around X axis |
RY | Rotation around Y axis |
RZ | Rotation around Z axis |
RPHI | R-Phi gate |
U1 | U1 gate (single-parameter) |
U2 | U2 gate (two-parameter) |
U3 | U3 gate (three-parameter) |
U4 | U4 gate (four-parameter) |
CU | Controlled-U gate |
CNOT | Controlled-NOT gate |
CZ | Controlled-Z gate |
CP | Controlled-Phase gate |
CRX | Controlled-RX gate |
CRY | Controlled-RY gate |
CRZ | Controlled-RZ gate |
RYY | YY rotation gate |
RXX | XX rotation gate |
RZZ | ZZ rotation gate |
RZX | ZX rotation gate |
ISWAP | iSWAP gate |
SQISWAP | Square-root iSWAP gate |
SWAP | SWAP gate |
IDLE | IDLE (no-operation) gate |
ECHO | Echo gate |
ORACLE | Oracle (user-defined unitary) gate |
TOFFOLI | Toffoli (CCNOT) gate |
BARRIER | Barrier operation |
MS | Molmer-Sorensen gate |
Example
python
from pyqpanda3.core import H, GateType
gate = H(0)
print(gate.gate_type()) # GateType.HOpType
Enumeration of operation types in a quantum program.
Values
| Value | Description |
|---|---|
Gate | A quantum gate operation |
Measure | A measurement operation |
Example
python
from pyqpanda3.core import H, OpType
gate = H(0)
op = gate # Operation with m_operation_type == OpType.GatePIC_TYPE
Enumeration of output formats for circuit visualization.
Note:
GateandMeasureare exported aliases inpyqpanda3.core.__init__:
Gate = OpType.GateMeasure = OpType.MeasureUse these aliases for brevity when checking operation types.
Values
| Value | Description |
|---|---|
TEXT | ASCII text visualization |
LATEX | LaTeX source for circuit diagram |
Example
python
from pyqpanda3.core import draw_qprog, QProg, H, CNOT, PIC_TYPE
prog = QProg()
prog << H(0) << CNOT(0, 1)
# Text visualization
text_output = draw_qprog(prog, PIC_TYPE.TEXT)
print(text_output)
# LaTeX visualization
latex_output = draw_qprog(prog, PIC_TYPE.LATEX)See Also
- Gates — All quantum gate functions
- Noise — NoiseModel using GateType
- Visualization — draw_qprog function
set_print_options
Configures global print options for quantum circuit and program text output. Affects how circuit diagrams are rendered when printed or converted to strings.
Signature
python
set_print_options(precision: int = 8, param_show: int = True, linewidth: int = 100) -> NoneParameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| precision | int | 8 | Floating-point precision for parameter values in output |
| param_show | int | True | Whether to show gate parameters in circuit output (True or False) |
| linewidth | int | 100 | Maximum number of characters per line in output |
Examples
python
from pyqpanda3.core import set_print_options, QCircuit, H, RX
# Set compact output with 4-digit precision
set_print_options(precision=4, linewidth=60)
circ = QCircuit()
circ << H(0) << RX(1, 0.123456789)
print(circ)