RPNGDescription#

class tqec.plaquette.RPNGDescription(corners, ancilla=RG(r=<BasisEnum.X: 'x'>, g=<BasisEnum.X: 'x'>))[source]#

Bases: object

Organize the description of a plaquette in RPNG format

The corners of the square plaquette are listed following the order: top-left, top-right, bottom-left, bottom-right. This forms a Z-shaped path on the plaquette corners:

1 —–> 2

/

/

3 —–> 4

If the ancilla RG description is not specified, it is assumed ‘xx’

Parameters:
corners RPNG description of the four corners of the plaquette
ancilla RG description of the ancilla

Methods

__init__(corners[, ancilla])

from_extended_string(...)

Initialize the RPNGDescription object from a (16+3)-character string

from_string(corners_rpng_string)

Initialize the RPNGDescription object from a (16+3)-character string

get_g_op(data_idx)

Get the measurement operation or Hadamard for the specific data qubit

get_n(data_idx)

Get the time of the 2Q gate involving the specific data qubit

get_r_op(data_idx)

Get the reset operation or Hadamard for the specific data qubit

view_as_svg([write_to_filepath, ...])

Visualize the RPNG description as an SVG image.

Attributes

ancilla

has_measurement

has_reset

corners

Detailed methods

__init__(corners, ancilla=RG(r=<BasisEnum.X: 'x'>, g=<BasisEnum.X: 'x'>))#
Parameters:
Return type:

None

classmethod from_extended_string(ancilla_and_corners_rpng_string)[source]#

Initialize the RPNGDescription object from a (16+3)-character string

Parameters:

ancilla_and_corners_rpng_string (str)

Return type:

RPNGDescription

classmethod from_string(corners_rpng_string)[source]#

Initialize the RPNGDescription object from a (16+3)-character string

Parameters:

corners_rpng_string (str)

Return type:

RPNGDescription

get_g_op(data_idx)[source]#

Get the measurement operation or Hadamard for the specific data qubit

Parameters:

data_idx (int)

Return type:

str | None

get_n(data_idx)[source]#

Get the time of the 2Q gate involving the specific data qubit

Parameters:

data_idx (int)

Return type:

int | None

get_r_op(data_idx)[source]#

Get the reset operation or Hadamard for the specific data qubit

Parameters:

data_idx (int)

Return type:

str | None

view_as_svg(write_to_filepath=None, canvas_height=100, opacity=1.0, show_rg_fields=True, show_interaction_order=True, show_hook_error=False)[source]#

Visualize the RPNG description as an SVG image.

Parameters:
  • write_to_filepath (str | Path | None) – the path to write the SVG image to.

  • canvas_height (int) – The height of the canvas in pixels.

  • opacity (float) – The opacity of the plaquettes.

  • show_rg_fields (bool) – Whether to show the R/G fields on the data qubits. If True, the R field is shown as a small rectangle at the position of the data qubit, whose color corresponds to the basis. The G field is shown as a small circle at the position of the data qubit, whose color corresponds to the basis.

  • show_interaction_order (bool) – Whether to show the interaction order of the plaquettes. If True, the interaction order is shown at each corner of the plaquette.

  • show_hook_error (bool) – Whether to highlight the plaquette with the hook error. If True, the hook error is shown as a black line along the hook edge.

Returns:

The SVG string representing the visualization.

Return type:

str