[docs]classInstructionMapping:def__init__(self,qiskit_to_os:dict[str,str]=_DEFAULT_QISKIT_TO_OPENSQUIRREL_MAPPING):self._QISKIT_TO_OPENSQUIRREL_MAPPING:dict[str,str]=qiskit_to_os# Uses lower case for keys to normalize inconsistent capitalization of backendsself._OPENSQUIRREL_TO_QISKIT_MAPPING:dict[str,str]={v.lower():kfork,vinself._QISKIT_TO_OPENSQUIRREL_MAPPING.items()}
[docs]defqiskit_to_opensquirrel(self,instruction:str)->str:"""Translate a Qiskit gate name to the equivalent opensquirrel gate name."""returnself._QISKIT_TO_OPENSQUIRREL_MAPPING[instruction.lower()]
[docs]defopensquirrel_to_qiskit(self,instruction:str)->str:"""Translate an opensquirrel gate name to the equivalent Qiskit gate name."""returnself._OPENSQUIRREL_TO_QISKIT_MAPPING[instruction.lower()]
[docs]defsupported_opensquirrel_instructions(self)->list[str]:"""Return a list of all supported opensquirrel instructions."""returnlist(self._QISKIT_TO_OPENSQUIRREL_MAPPING.values())
[docs]defsupported_qiskit_instructions(self)->list[str]:"""Return a list of all supported Qiskit instructions."""returnlist(self._QISKIT_TO_OPENSQUIRREL_MAPPING.keys())