Skip to content

check_mapper

This module contains checks for the Mapper pass.

check_mapper(mapper)

Check if the mapper complies with the OpenSquirrel requirements.

If a Mapper implementation passes these checks, it should be compatible with the Circuit.map method.

Parameters:

Name Type Description Default
mapper Mapper

Mapper to check.

required
Source code in opensquirrel/utils/check_mapper.py
def check_mapper(mapper: Mapper) -> None:
    """Check if the `mapper` complies with the OpenSquirrel requirements.

    If a ``Mapper`` implementation passes these checks, it should be compatible with the ``Circuit.map`` method.

    Args:
        mapper: Mapper to check.
    """
    assert isinstance(mapper, Mapper)

    register_manager = RegisterManager(QubitRegister(10), BitRegister(10))
    ir = IR()
    circuit = Circuit(register_manager, ir)
    _check_scenario(circuit, mapper)

    ir = IR()
    ir.add_gate(BlochSphereRotation(42, (1, 0, 0), 1, 2))
    ir.add_gate(ControlledGate(42, I(100)))
    ir.add_non_unitary(Measure(42, 42, (0, 0, 1)))
    Circuit(register_manager, ir)
    _check_scenario(circuit, mapper)