tqec.circuit.qubit_map.QubitMap#

class QubitMap(i2q: dict[int, ~tqec.circuit.qubit.GridQubit] = <factory>)[source]#

Represent a bijection between GridQubit instances and indices.

This class aims at representing a bidirectional mapping (hence the “bijection”) between qubits and their associated indices.

Raises:

TQECException – if the provided mapping from indices to qubits is not a bijection (i.e., if at least to values represent the same qubit).

__init__(i2q: dict[int, ~tqec.circuit.qubit.GridQubit] = <factory>) None#

Methods

__init__([i2q])

filter_by_qubits(qubits_to_keep)

Filter the qubit map to only keep qubits present in the provided qubits_to_keep.

from_circuit(circuit)

from_qubits(qubits)

Creates a qubit map from the provided qubits, associating indices using the order in which qubits are provided.

items()

to_circuit()

Get a circuit with only QUBIT_COORDS instructions representing self.

with_mapped_qubits(qubit_map)

Change the qubits involved in self without changing the associated indices.

Attributes

indices

q2i

qubits

i2q