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)
whenNone
Methods
__init__
([default_increments])Construct an instance of the template.
get_border_indices
(border)Returns the indices on the provided
border
.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.
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)
whenNone
- 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:
- 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 theTemplate
instance) at its center should be ignored. Default toTrue
.
- 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)
ifNone
.
- 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 byinstantiate()
.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 byinstantiate()
.- Return type: