Skip to content

general_mapper

This module contains generic mapping components.

Mapper

Base class for the Mapper pass.

Source code in opensquirrel\mapper\general_mapper.py
class Mapper:
    """Base class for the Mapper pass."""

    def __init__(self, qubit_register_size: int, mapping: Mapping | None = None) -> None:
        """Use ``IdentityMapper`` as the fallback case for ``Mapper``"""
        physical_qubit_register = list(range(qubit_register_size))
        self.mapping = mapping if mapping is not None else Mapping(physical_qubit_register)

        if qubit_register_size != self.mapping.size():
            msg = "qubit register size and mapping size differ"
            raise ValueError(msg)

    def get_mapping(self) -> Mapping:
        """Get mapping."""
        return self.mapping

__init__(qubit_register_size, mapping=None)

Use IdentityMapper as the fallback case for Mapper

Source code in opensquirrel\mapper\general_mapper.py
def __init__(self, qubit_register_size: int, mapping: Mapping | None = None) -> None:
    """Use ``IdentityMapper`` as the fallback case for ``Mapper``"""
    physical_qubit_register = list(range(qubit_register_size))
    self.mapping = mapping if mapping is not None else Mapping(physical_qubit_register)

    if qubit_register_size != self.mapping.size():
        msg = "qubit register size and mapping size differ"
        raise ValueError(msg)

get_mapping()

Get mapping.

Source code in opensquirrel\mapper\general_mapper.py
def get_mapping(self) -> Mapping:
    """Get mapping."""
    return self.mapping