qc2.algorithms.utils.mappers

This module creates a wrapper around qiskit-nature mappers.

Module Contents

Classes

FermionicToQubitMapper

class qc2.algorithms.utils.mappers.FermionicToQubitMapper[source]
_mappers[source]
classmethod register_mapper(key: str, mapper: qiskit_nature.second_q.mappers.QubitMapper)[source]

Register a new mapper class with a given key.

Parameters:
  • key (str) – The key (name) for the mapper.

  • mapper (QubitMapper) – The mapper class to be registered.

Raises:

ValueError – If the key is already registered.

Example

>>> from qiskit_nature.second_q.mappers import TaperedQubitMapper
>>> from qc2.algorithms.utils import FermionicToQubitMapper
>>>
>>> FermionicToQubitMapper.register_mapper('TQM', TaperedQubitMapper)
>>> mapper = FermionicToQubitMapper.from_string('tqm')
classmethod from_string(s)[source]

Retrieve the mapper class corresponding to the provided string.

Parameters:

s (str) – The string identifier of the mapper. Case-insensitive.

Returns:

The corresponding mapper class.

Return type:

QubitMapper

Raises:

ValueError – If the provided string does not correspond to any known mapper.

Example

>>> from qc2.algorithms.utils import FermionicToQubitMapper
>>> mapper = FermionicToQubitMapper.from_string('jw'))