QubitTemplate#

class tqec.templates.QubitTemplate(default_increments=None)[source]#

Bases: RectangularTemplate

An error-corrected qubit.

The below text represents this template for an input k == 2

1  5  6  5  6  2
7  9 10  9 10 11
8 10  9 10  9 12
7  9 10  9 10 11
8 10  9 10  9 12
3 13 14 13 14  4

Construct an instance of the template.

Parameters:

default_increments (Shift2D | None) – default increments between two plaquettes. Defaults to Displacement(2, 2) when None

Methods

__init__([default_increments])

Construct an instance of the template.

get_border_indices(border)

Returns the indices on the provided border.

get_increments()

Get the default increments of the template.

get_spatially_distinct_subtemplates(k[, ...])

Returns a representation of all the distinct sub-templates of the provided manhattan radius.

instantiate(k[, plaquette_indices])

Generate the numpy array representing the template.

instantiation_origin(k)

Coordinates of the top-left entry origin.

shape(k)

Returns the current template shape.

Attributes

expected_plaquettes_number

Returns the number of plaquettes expected from the instantiate() method.

scalable_shape

Returns a scalable version of the template shape.

Detailed methods

__init__(default_increments=None)#

Construct an instance of the template.

Parameters:

default_increments (Shift2D | None) – default increments between two plaquettes. Defaults to Displacement(2, 2) when None

Return type:

None

get_border_indices(border)[source]#

Returns the indices on the provided border.

Parameters:

border (TemplateBorder) – side of the template instance for which the indices are needed.

Returns:

a description of the indices present on the provided border of the represented template.

Return type:

BorderIndices

get_increments()#

Get the default increments of the template.

Returns:

a displacement of the default increments in the x and y directions.

Return type:

Shift2D

get_spatially_distinct_subtemplates(k, manhattan_radius=1, avoid_zero_plaquettes=True)#

Returns a representation of all the distinct sub-templates of the provided manhattan radius.

Note

This method will likely be inefficient for large templates (i.e., large values of k) or for large Manhattan radiuses, both in terms of memory used and computation time. Subclasses are invited to reimplement that method using a specialized algorithm (or hard-coded values) to speed things up.

Parameters:
  • k (int) – scaling parameter used to instantiate the template.

  • manhattan_radius (int) – radius of the considered ball using the Manhattan distance. Only squares with sides of 2*manhattan_radius+1 plaquettes will be considered.

  • avoid_zero_plaquettes (bool) – True if sub-templates with an empty plaquette (i.e., 0 value in the instantiation of the Template instance) at its center should be ignored. Default to True.

Returns:

a representation of all the sub-templates found.

Return type:

UniqueSubTemplates

instantiate(k, plaquette_indices=None)[source]#

Generate the numpy array representing the template.

Parameters:
  • k (int) – scaling parameter used to instantiate the template.

  • plaquette_indices (Sequence[int] | None) – the plaquette indices that will be forwarded to the underlying Shape instance’s instantiate method. Defaults to range(1, self.expected_plaquettes_number + 1) if None.

Returns:

a numpy array with the given plaquette indices arranged according to the underlying shape of the template.

Return type:

ndarray[Any, dtype[int64]]

instantiation_origin(k)#

Coordinates of the top-left entry origin.

This property returns the coordinates of the origin of the plaquette (origin) that corresponds to the top-left entry of the array returned by instantiate().

Note

the returned coordinates are in plaquette coordinates. That means that, if you want to get the coordinates of the top-left plaquette origin (which is a qubit), you should multiply the coordinates returned by this method by the tiling increments.

Parameters:

k (int) – scaling parameter used to instantiate the template.

Returns:

the coordinates of the origin of the plaquette (origin) that corresponds to the top-left entry of the array returned by instantiate().

Return type:

PlaquettePosition2D

shape(k)#

Returns the current template shape.

Parameters:

k (int)

Return type:

Shape2D