BaseComposedLayer#
- class tqec.compile.blocks.BaseComposedLayer(trimmed_spatial_borders=frozenset({}))[source]#
Bases:
WithSpatialFootprint
,WithTemporalFootprint
Base class representing a composed “layer”.
A composed layer is defined as a sequence (in time) of atomic layers. As such, composed layers are expected to have either a scalable time footprint (i.e., that grows with
k
) or a constant time footprint that is strictly greater than1
.Initialise the instance.
- Parameters:
removed_spatial_borders – all the spatial borders that have been trimmed from the layer.
trimmed_spatial_borders (frozenset[SpatialBlockBorder])
Methods
__init__
([trimmed_spatial_borders])Initialise the instance.
all_layers
(k)Returns all the base layers represented by the instance.
get_temporal_layer_on_border
(border)shape
(k)Returns the 2-dimensional shape of the object for the given
k
.timesteps
(k)Returns the number of timesteps needed to implement the object for the provided scaling parameter
k
.to_sequenced_layer_with_schedule
(schedule)Splits
self
into aSequencedLayers
instance with the provided schedule.with_spatial_borders_trimmed
(borders)Returns
self
with the provided spatial borders removed.Returns
self
with the provided temporal borders replaced.Attributes
scalable_shape
Returns the 2-dimensional shape of the object as an exact expression that can then be used to compute the shape for any value of
k
.scalable_timesteps
Returns the number of timesteps needed to implement the object as an exact expression that can then be used to compute the number of timesteps for any value of
k
.trimmed_spatial_borders
Detailed methods
- __init__(trimmed_spatial_borders=frozenset({}))#
Initialise the instance.
- Parameters:
removed_spatial_borders – all the spatial borders that have been trimmed from the layer.
trimmed_spatial_borders (frozenset[SpatialBlockBorder])
- abstract all_layers(k)[source]#
Returns all the base layers represented by the instance.
- Returns:
All the base layers represented by the instance. The returned iterable should have as many entries as
self.timesteps(k)
.- Parameters:
k (int)
- Return type:
Iterable[BaseLayer]
- abstract get_temporal_layer_on_border(border)#
- Parameters:
border (TemporalBlockBorder)
- Return type:
- shape(k)#
Returns the 2-dimensional shape of the object for the given
k
.- Parameters:
k (int) – scaling parameter.
- Returns:
the 2-dimensional shape of the object for the given
k
.- Return type:
PhysicalQubitShape2D
- timesteps(k)#
Returns the number of timesteps needed to implement the object for the provided scaling parameter
k
.- Parameters:
k (int) – scaling parameter.
- Returns:
the number of timesteps needed to implement the object for the provided scaling parameter
k
.- Return type:
int
- abstract to_sequenced_layer_with_schedule(schedule)[source]#
Splits
self
into aSequencedLayers
instance with the provided schedule.- Parameters:
schedule (tuple[LinearFunction, ...]) – duration of each of the layers in the returned
SequencedLayers
instance.- Returns:
an instance of
SequencedLayers
that is equivalent toself
(same duration, same layers applied, …) and that has the providedschedule
.- Return type:
- abstract with_spatial_borders_trimmed(borders)#
Returns
self
with the provided spatial borders removed.- Parameters:
borders (Iterable[SpatialBlockBorder]) – spatial borders to remove.
- Returns:
a copy of
self
with the providedborders
removed.- Return type:
Self
- abstract with_temporal_borders_replaced(border_replacements)#
Returns
self
with the provided temporal borders replaced.- Parameters:
borders – a mapping from temporal borders to replace to their replacement. A value of
None
as a replacement means that the border is removed.border_replacements (Mapping[TemporalBlockBorder, BaseLayer | None])
- Returns:
a copy of
self
with the providedborders
replaced, orNone
if replacing the providedborders
fromself
result in an empty temporal footprint.- Return type:
BaseLayer | BaseComposedLayer | None