A circuit has a register manager.
A register manager only holds, for the moment, a (virtual) qubit and bit register size and names.
The bit register size is set to that of the qubit register.
Add Mapping class
A mapping is a dictionary from a (virtual) qubit register to a physical qubit register.
Mapping correctness is a class invariant. I.e., it is checked during the construction of the mapping.
Change relabel code into _QubitRemapper
_QubitRemapper implements SquirrelIRVisitor to update the qubit indices according to a Mapping.
Update circuit.map
Remove maq_qubits free function and rename circuit.map_qubits to circuit.map (to be consistent with circuit.decompose and so on).
A mapper is created with a valid mapping and then returns its mapping through get_mapping().
circuit.map invokes remap_ir with a given mapper.get_mapping(), and remap_ir uses an SquirrelIRVisitor to update the qubit indices.
Remove SquirrelIR's number of qubits and qubit register name
This information is accessed through the circuit's register manager.
Move _QubitReindexer code to reindexer/qubit_reindexer.py.
Rename check_valid_replacement to check_gate_replacement.
Rename get_matrix_after_qubit_remapping to get_circuit_matrix(get_reindexed_circuit()).
Rename qubit_mappings to qubit_indices.
Add tests for _QubitReindexer and _QubitRemapper.
Rename parser/libqasm/libqasm_ir_creator.py to parser/libqasm/parser.py.
Add
RegisterManager
classA circuit has a register manager. A register manager only holds, for the moment, a (virtual) qubit and bit register size and names. The bit register size is set to that of the qubit register.
Add
Mapping
classA mapping is a dictionary from a (virtual) qubit register to a physical qubit register. Mapping correctness is a class invariant. I.e., it is checked during the construction of the mapping.
Change
relabel
code into_QubitRemapper
_QubitRemapper
implementsSquirrelIRVisitor
to update the qubit indices according to aMapping
.Update
circuit.map
Remove
maq_qubits
free function and renamecircuit.map_qubits
tocircuit.map
(to be consistent withcircuit.decompose
and so on). A mapper is created with a valid mapping and then returns its mapping throughget_mapping()
.circuit.map
invokesremap_ir
with a givenmapper.get_mapping()
, andremap_ir
uses anSquirrelIRVisitor
to update the qubit indices.Remove
SquirrelIR
's number of qubits and qubit register nameThis information is accessed through the circuit's register manager.
Move
_QubitReindexer
code toreindexer/qubit_reindexer.py
.Rename
check_valid_replacement
tocheck_gate_replacement
. Renameget_matrix_after_qubit_remapping
toget_circuit_matrix(get_reindexed_circuit())
. Renamequbit_mappings
toqubit_indices
.Add tests for
_QubitReindexer
and_QubitRemapper
.Rename
parser/libqasm/libqasm_ir_creator.py
toparser/libqasm/parser.py
.