Feature Description
Implement a.merge() method with automatic unrolling and register consolidation.
- Purpose:
Merge two QasmModule objects into a single module, handling all register consolidation and unrolling transparently.
- Consolidation & Unrolling:
- All register consolidation and unrolling is performed automatically during the merge.
- Uses the existing
.unroll(device_qubits) method to ensure both modules are unrolled and consolidated before merging.
- User Experience:
- The user only needs to call
.merge() on one module, passing the other as an argument.
- No manual unrolling or consolidation is required.
- Output:
- Returns a new, merged module (preferred for immutability).
- All qubit and classical registers are consolidated into
__PYQASM_QUBITS__ and __PYQASM_CLASSICAL__.
Implementation (Optional)
- Unroll and Consolidate Both Modules:
- Call
.unroll(device_qubits=...) on both modules before merging.
- If
device_qubits is not specified, use a default large enough to hold all qubits.
- This ensures all registers are consolidated and unrolled.
- Merge Gates and Operation History:
- Append gates from the second module after the first.
- Combine operation history lists.
- Consolidate the Merged Module (Optional, but Safe):
- If the merge could introduce new registers (unlikely if both are already consolidated), perform a final consolidation.
- This step is mostly redundant but ensures robustness.
- Return the New Module:
- Return a new
QasmModule with the merged content.
Feature Description
Implement a
.merge()method with automatic unrolling and register consolidation.Merge two
QasmModuleobjects into a single module, handling all register consolidation and unrolling transparently..unroll(device_qubits)method to ensure both modules are unrolled and consolidated before merging..merge()on one module, passing the other as an argument.__PYQASM_QUBITS__and__PYQASM_CLASSICAL__.Implementation (Optional)
.unroll(device_qubits=...)on both modules before merging.device_qubitsis not specified, use a default large enough to hold all qubits.QasmModulewith the merged content.