Skip to content

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

ValueDescription
GATE_NOPNo operation (identity placeholder)
GATE_UNDEFINEDUndefined gate type
IIdentity gate
XPauli-X (NOT) gate
YPauli-Y gate
ZPauli-Z gate
X1SX gate (X)
Y1Y1 gate (Y)
Z1Z1 gate (Z)
HHadamard gate
TT gate (π/8 gate)
SS gate (phase gate)
PParameterized phase gate
RXRotation around X axis
RYRotation around Y axis
RZRotation around Z axis
RPHIR-Phi gate
U1U1 gate (single-parameter)
U2U2 gate (two-parameter)
U3U3 gate (three-parameter)
U4U4 gate (four-parameter)
CUControlled-U gate
CNOTControlled-NOT gate
CZControlled-Z gate
CPControlled-Phase gate
CRXControlled-RX gate
CRYControlled-RY gate
CRZControlled-RZ gate
RYYYY rotation gate
RXXXX rotation gate
RZZZZ rotation gate
RZXZX rotation gate
ISWAPiSWAP gate
SQISWAPSquare-root iSWAP gate
SWAPSWAP gate
IDLEIDLE (no-operation) gate
ECHOEcho gate
ORACLEOracle (user-defined unitary) gate
TOFFOLIToffoli (CCNOT) gate
BARRIERBarrier operation
MSMolmer-Sorensen gate

Example

python
from pyqpanda3.core import H, GateType

gate = H(0)
print(gate.gate_type())  # GateType.H

OpType

Enumeration of operation types in a quantum program.

Values

ValueDescription
GateA quantum gate operation
MeasureA measurement operation

Example

python
from pyqpanda3.core import H, OpType

gate = H(0)
op = gate  # Operation with m_operation_type == OpType.Gate

PIC_TYPE

Enumeration of output formats for circuit visualization.

Note: Gate and Measure are exported aliases in pyqpanda3.core.__init__:

  • Gate = OpType.Gate
  • Measure = OpType.Measure

Use these aliases for brevity when checking operation types.

Values

ValueDescription
TEXTASCII text visualization
LATEXLaTeX 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


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) -> None

Parameters

ParameterTypeDefaultDescription
precisionint8Floating-point precision for parameter values in output
param_showintTrueWhether to show gate parameters in circuit output (True or False)
linewidthint100Maximum 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)

Released under the MIT License.