pygsti.models.stencillabel.StencilLabel#
- class StencilLabel(local_state_space=None)#
Bases:
objectA generalization of a simple tuple of state space labels.
A
StencilLabelcan be a simple tuple of absolute state space labels, but it can also contain special labels identifying the target labels of a gate (@<int>) and qubit-graph directions relative to target labels, e.g. @0+left. Furthermore, a stencil label can expand into multiple state-space label tuples, e.g. the 2-tuples of all the qubit-graph edges.- Parameters:
local_state_space (StateSpace) – A manually supplied local state space for this label, which is returned by
create_local_state_space()instead of generating a local state space.
Methods
__init__([local_state_space])cast(obj)Convert an object into a stencil label if it isn't already.
compute_absolute_sslbls(qubit_graph, ...)Creates a list of all the state space label tuples this stencil label expands into.
create_local_state_space(entire_state_space)Creates a "local" state space for an operator indexed using this stencil label.
- classmethod cast(obj)#
Convert an object into a stencil label if it isn’t already.
- Parameters:
obj (object) – The object to convert.
- Return type:
- compute_absolute_sslbls(qubit_graph, state_space, target_lbls)#
Creates a list of all the state space label tuples this stencil label expands into.
To perform the expansion, the qubit graph of the relevant processor is required, along with the target state space labels, which determine where the stencil is placed on the qubit graph. The returned list of tuples contains absolute state space labels, meaning that they are labels in state_space and do not use any special directives.
- Parameters:
qubit_graph (QubitGraph) – The qubit graph of the relevant processor, used to resolve any special stencil labels.
state_space (StateSpace) – The state space for the entire processor. This specifies what the state space labels are.
target_lbls (tuple) – The target state space labels, specifying where the stencil is placed on the qubit graph before being expanded into absolute state space labels.
- Returns:
The state space label tuples this stencil label expands into, e.g. [(‘Q0’,’Q1’), (‘Q1’,’Q2’)].
- Return type:
list
- create_local_state_space(entire_state_space)#
Creates a “local” state space for an operator indexed using this stencil label.
When creating operator objects, a stencil label specifies where to place (embed) operators on some subset of the entire space. When these to-be-embedded operations are constructed, they need to be supplied with a state space that just corresponds to the sub-space where they act – a “local” state space. A stencil label expands into one or more state space label tuples, and this function constructs a single local state space that is appropriate for any and all of these tuples (i.e. what is returned by
compute_absolute_sslbls()), and that is therefore appropriate for constructing the to-be-embedded operation. Importantly, this function can be called without knowing where this stencil label will be placed, that is, it doesn’t require a “target labels” argument.- Parameters:
entire_state_space (StateSpace) – The entire state space of the relevant processor, specifying the state space labels and information about them.
- Return type: