Pattern data structure

graphix.command module

This module defines standard data structure for pattern commands.

Data validator command classes.

class graphix.command.CommandKind(value)[source]

Tag for command kind.

class graphix.command.N(node: int, state: ~graphix.states.State = <factory>)[source]

Preparation command.

class graphix.command.M(node: int, plane: ~graphix.fundamentals.Plane = Plane.XY, angle: float = 0.0, s_domain: set[int] = <factory>, t_domain: set[int] = <factory>)[source]

Measurement command. By default the plane is set to ‘XY’, the angle to 0, empty domains and identity vop.

class graphix.command.E(nodes: tuple[int, int])[source]

Entanglement command.

class graphix.command.C(node: int, clifford: Clifford)[source]

Clifford command.

class graphix.command.X(node: int, domain: set[int] = <factory>)[source]

X correction command.

class graphix.command.Z(node: int, domain: set[int] = <factory>)[source]

Z correction command.

class graphix.command.MeasureUpdate(new_plane: Plane, coeff: int, add_term: float)[source]

Describe how a measure is changed by the signals and/or a vertex operator.

graphix.fundamentals module

This module defines standard data structure for Pauli operators.

Fundamental components related to quantum mechanics.

class graphix.fundamentals.Axis(value)[source]

Axis: X, Y or Z.

property matrix: npt.NDArray[np.complex128]

Return the matrix representation.

class graphix.fundamentals.ComplexUnit(value)[source]

Complex unit: 1, -1, j, -j.

Complex units can be multiplied with other complex units, with Python constants 1, -1, 1j, -1j, and can be negated.

static from_properties(*, sign: Sign = Sign.PLUS, is_imag: bool = False) ComplexUnit[source]

Construct ComplexUnit from its properties.

property is_imag: bool

Return True if j or -j.

property sign: Sign

Return the sign.

static try_from(value: ComplexUnit | SupportsComplex | SupportsFloat | SupportsIndex | complex) ComplexUnit | None[source]

Return the ComplexUnit instance if the value is compatible, None otherwise.

class graphix.fundamentals.Sign(value)[source]

Sign, plus or minus.

static minus_if(b: bool) Sign[source]

Return - if b is True, + otherwise.

static plus_if(b: bool) Sign[source]

Return + if b is True, - otherwise.

class graphix.fundamentals.IXYZ(value)[source]

I, X, Y or Z.

property matrix: npt.NDArray[np.complex128]

Return the matrix representation.

class graphix.fundamentals.Plane(value)[source]

Plane: XY, YZ or XZ.

property axes: tuple[Axis, Axis]

Return the pair of axes that carry the plane.

property cos: Axis

Return the axis of the plane that conventionally carries the cos.

static from_axes(a: Axis, b: Axis) Plane[source]

Return the plane carried by the given axes.

property orth: Axis

Return the axis orthogonal to the plane.

polar(angle: float) tuple[float, float, float][source]

Return the Cartesian coordinates of the point of module 1 at the given angle, following the conventional orientation for cos and sin.

property sin: Axis

Return the axis of the plane that conventionally carries the sin.

graphix.pauli module

This module defines standard data structure for Pauli operators.

Pauli gates ± {1,j} × {I, X, Y, Z}.

class graphix.pauli.Pauli(symbol: IXYZ = IXYZ.I, unit: ComplexUnit = ComplexUnit.ONE)[source]

Pauli gate: u * {I, X, Y, Z} where u is a complex unit.

Pauli gates can be multiplied with other Pauli gates (with @), with complex units and unit constants (with *), and can be negated.

graphix.instruction module

This module defines standard data structure for gate seqence (circuit model) used for graphix.transpiler.Circuit.

Instruction classes.

class graphix.instruction.InstructionKind(value)[source]

Tag for instruction kind.

class graphix.instruction.RX(target: int, angle: float, meas_index: int | None = None)[source]

X rotation circuit instruction.

class graphix.instruction.RZ(target: int, angle: float, meas_index: int | None = None)[source]

Z rotation circuit instruction.

class graphix.instruction.RY(target: int, angle: float, meas_index: int | None = None)[source]

Y rotation circuit instruction.

class graphix.instruction.M(target: int, plane: Plane, angle: float)[source]

M circuit instruction.

class graphix.instruction.X(target: int)[source]

X circuit instruction.

class graphix.instruction.Y(target: int)[source]

Y circuit instruction.

class graphix.instruction.Z(target: int)[source]

Z circuit instruction.

class graphix.instruction.S(target: int)[source]

S circuit instruction.

class graphix.instruction.H(target: int)[source]

H circuit instruction.

class graphix.instruction.SWAP(targets: tuple[int, int])[source]

SWAP circuit instruction.

class graphix.instruction.CNOT(target: int, control: int)[source]

CNOT circuit instruction.

graphix.states module

Quantum states and operators.

class graphix.states.State[source]

Abstract base class for single qubit states objects.

Only requirement for concrete classes is to have a get_statevector() method that returns the statevector representation of the state