Code elements¶
-
class
qsurface.codes.elements.
Qubit
(loc, z=0, *args, **kwargs)¶ General type qubit object.
# This class mainly serves as a superclass or template to other more useful qubit types, which have the apprioate subclass attributes and subclass methods. For other types to to the ‘See Also’ section.
-
class
qsurface.codes.elements.
DataQubit
(*args, **kwargs)¶ Data type qubit object.
The state of a data-qubit is determined by two
Edge
objects stored in theself.edges
dictionary. Each of the edges are part of a separate graph on the surface lattice.-
edges
¶ Dictionary of edges with the error type as key (e.g.
"x"
or"z"
).self.edges = {“x”: Edge_x, “z”, Edge_z}
- Type
dict of
Edge
-
state
¶ A class property that calls to each of the edges stored at the
self.edges
attribute and returns all edge states as a dictionary.- Type
dict of bool
-
-
class
qsurface.codes.elements.
AncillaQubit
(*args, state_type='default', **kwargs)¶ General type qubit object.
An ancilla-qubit is entangled to one or more
DataQubit
objects. Theself.state_type
attribute determines the state on which the measurement is applied. A single measurement is applied when the class propertyself.state
is called. The state of the last measurement is stored inself.measured_state
for state access without prompting a new measurement.- Parameters
state_type (str, {"x", "z"}) – Type of ‘codes.elements.Edge’ objects belonging to the
DataQubit
objects entangled to the current ancilla-qubit for stabilizer measurements.
-
parity_qubits
¶ All qubits in this dictionary are entangled to the current ancilla for stabilizer measurements.
- Type
dict of
DataQubit
-
z_neighbors
¶ Neighbor ancilla in the z direction that is an instance of the same qubit at a different time, required for faulty measurements.
Examples
The state of the entangled
DataQubit
is located at:>>> AncillaQubit.parity_qubits[key].edges[AncillaQubit.state_type] True
-
measure
(p_bitflip_plaq=0, p_bitflip_star=0, **kwargs)¶ Applies a parity measurement on the ancilla.
The functions loops over all the data qubits in
self.parity_qubits
. For every edge associated with the entangled state on the data qubit, the value of aparity
boolean is flipped.
-
class
qsurface.codes.elements.
Edge
(qubit, state_type='', initial_state=None, **kwargs)¶ A state object belonging to a
DataQubit
object.An edge cannot have open vertices and must be spanned by two nodes. In this case, the two nodes must be
AncillaQubit
objects, and are stored inself.nodes
.- Parameters
-
nodes
¶ The vertices that spans the edge.
- Type
list of two ~.codes.elements.AncillaQubit` objects
-
add_node
(node, **kwargs)¶ Adds a node to the edge’s
self.nodes
attribute.
-
class
qsurface.codes.elements.
PseudoQubit
(*args, state_type='default', **kwargs)¶ Boundary element, imitates
codes.elements.AncillaQubit
.Edges needs to be spanned by two nodes. For data qubits on the boundary, one of its edges additionally requires an ancilla qubit like node, which is the pseudo-qubit.
-
measure
(p_bitflip_plaq=0, p_bitflip_star=0, **kwargs)¶ Applies a parity measurement on the ancilla.
The functions loops over all the data qubits in
self.parity_qubits
. For every edge associated with the entangled state on the data qubit, the value of aparity
boolean is flipped.
-
-
class
qsurface.codes.elements.
PseudoEdge
(qubit, state_type='', initial_state=None, **kwargs)¶ Vertical edge connecting time instances of ancilla-qubits, imitates
codes.elements.Edge
.-
add_node
(node, **kwargs)¶ Adds a node to the edge’s
self.nodes
attribute.
-