Common

graphqomb.common module

Common classes and functions.

This module provides:

Enums

class graphqomb.common.Plane

Measurement planes for MBQC.

We distinguish the axial measurements from the planar measurements.

XY

Arbitrary-angle measurement on the XY plane.

YZ

Arbitrary-angle measurement on the YZ plane.

XZ

Arbitrary-angle measurement on the XZ plane.

class graphqomb.common.Axis

Measurement axis for Pauli measurement.

X

Pauli X-axis.

Y

Pauli Y-axis.

Z

Pauli Z-axis.

class graphqomb.common.Sign

Measurement sign for Pauli measurement.

PLUS

Positive sign.

MINUS

Negative sign.

Abstract Base Classes

class graphqomb.common.MeasBasis[source]

Bases: ABC

Abstract class to represent a measurement basis.

abstract property plane: Plane

Return the measurement plane.

abstract property angle: float

Return the measurement angle.

abstractmethod flip()[source]

Flip the measurement basis.

abstractmethod conjugate()[source]

Return the angle-conjugated measurement basis.

abstractmethod vector()[source]

Return the measurement basis vector.

Measurement Basis Classes

class graphqomb.common.PlannerMeasBasis[source]

Bases: MeasBasis

Class to represent a planner measurement basis.

__init__(plane, angle)[source]
property plane: Plane

Return the measurement plane.

Returns:

measurement plane

Return type:

Plane

property angle: float

Return the measurement angle.

Returns:

measurement angle

Return type:

float

flip()[source]

Flip the measurement basis.

Returns:

flipped PlannerMeasBasis

Return type:

PlannerMeasBasis

conjugate()[source]

Return the angle-conjugated PlannerMeasBasis object.

This operation represents measurement-angle sign inversion. It is not defined as complex conjugation of the basis vector.

Returns:

angle-conjugated PlannerMeasBasis

Return type:

PlannerMeasBasis

Raises:

TypeError – if the plane is not one of XY, YZ, XZ

vector()[source]

Return the measurement basis vector.

Returns:

measurement basis vector

Return type:

numpy.typing.NDArray[numpy.complex128]

class graphqomb.common.AxisMeasBasis[source]

Bases: MeasBasis

Class to represent an axis measurement basis.

The aim is to pocess the accurate information of the axis measurement.

axis

measurement axis

Type:

Axis

sign

measurement sign

Type:

Sign

__init__(axis, sign)[source]
property plane: Plane

Return the measurement plane.

Returns:

measurement plane

Return type:

Plane

Raises:

TypeError – if the axis is not one of X, Y, Z

property angle: float

Return the measurement angle.

Returns:

measurement angle

Return type:

float

Raises:

TypeError – if the axis is not one of X, Y,

flip()[source]

Flip the measurement basis.

Returns:

flipped AxisMeasBasis

Return type:

AxisMeasBasis

conjugate()[source]

Return the conjugate of the AxisMeasBasis object.

Returns:

conjugate AxisMeasBasis

Return type:

AxisMeasBasis

vector()[source]

Return the measurement basis vector.

Returns:

measurement basis vector

Return type:

numpy.typing.NDArray[numpy.complex128]

Functions

graphqomb.common.is_close_angle(angle, target, atol=1e-09)[source]

Check if an angle is close to a target angle.

Parameters:
  • angle (float) – angle to check

  • target (float) – target angle

  • atol (float, optional) – absolute tolerance, by default 1e-9

Returns:

True if the angle is close to the target angle

Return type:

bool

graphqomb.common.is_clifford_angle(angle, atol=1e-09)[source]

Check if an angle is a Clifford angle.

Parameters:
  • angle (float) – angle to check

  • atol (float, optional) – absolute tolerance, by default 1e-9

Returns:

True if the angle is a Clifford angle

Return type:

bool

graphqomb.common.determine_pauli_axis(meas_bases)[source]

Determine Pauli axis for a measurement basis if it’s a Pauli measurement.

Parameters:

meas_bases (MeasBasis) – Measurement basis to check

Returns:

Pauli axis if this is a Pauli measurement, None otherwise

Return type:

Axis | None

graphqomb.common.default_meas_basis()[source]

Return the default measurement basis.

The default measurement basis is the XY plane with angle 0.

Returns:

default measurement basis

Return type:

PlannerMeasBasis

graphqomb.common.meas_basis(plane, angle)[source]

Return the measurement basis vector corresponding to the plane and angle.

Parameters:
  • plane (Plane) – measurement plane

  • angle (float) – measurement angle

Returns:

measurement basis vector

Return type:

numpy.typing.NDArray[numpy.complex128]

Raises:

TypeError – if the plane is not one of XY, YZ, XZ