:py:mod:`qsearch.assemblers` ============================ .. py:module:: qsearch.assemblers .. autoapi-nested-parse:: This module defines the Assembler class, which is used to convert a Qsearch-style circuit into other formats, such as Qiskit or Qasm. The DictionaryAssembler subclass is provided as the default implementation of an Assembler. Use it as-is or as an example for writing your own Assembler. Some constants are also defined as DictionaryAssembler instances preloaded with the most common assembly dictionaries. .. attribute:: ASSEMBLER_QISKIT Outputs Python code that generates a Qiskit circuit object. .. attribute:: ASSEMBLER_OPENQASM Outputs generic Openqasm code. This may not be compatible with IBM Qiskit. .. attribute:: ASSEMBLER_IBMOPENQASM Outputs Openqasm code with the IBM imports and gate names. This flavor of Openqasm is compatible with IBM Qiskit. .. attribute:: ASSEMBLER_QUTRIT Outputs pseudocode for circuits built with single-qutrit gates and CNOTs. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: qsearch.assemblers.Assembler qsearch.assemblers.DictionaryAssembler Functions ~~~~~~~~~ .. autoapisummary:: qsearch.assemblers.flatten_intermediate Attributes ~~~~~~~~~~ .. autoapisummary:: qsearch.assemblers.assemblydict_qiskit qsearch.assemblers.assemblydict_openqasm qsearch.assemblers.assemblydict_ibmopenqasm qsearch.assemblers.assemblydict_qutrit qsearch.assemblers.ASSEMBLER_QISKIT qsearch.assemblers.ASSEMBLER_OPENQASM qsearch.assemblers.ASSEMBLER_IBMOPENQASM qsearch.assemblers.ASSEMBLER_QUTRIT .. py:class:: Assembler(options=Options()) This class is used to translate Qsearch-style circuits to other formats. .. py:method:: assemble(resultdict, options=None) :abstractmethod: The assemble function is used to convert the circuit described in resultdict. See DictionaryAssembler for an example implementation. :param resultdict: The dictionary representing the desired circuit. It is expected to contain the entries "stucture" and "parameters". It may contain other entries. :returns: A string representing the converted circuit code. :rtype: str .. py:class:: DictionaryAssembler(options=Options()) Bases: :py:obj:`Assembler` This subclass of Assembler uses a dictionary that specifies mappings from gate names to output code, as well as an output code initial line. Options: assemblydict (required) : A dictionary that specifies mappings from gate names to output code. .. py:method:: assemble(resultdict, options=None) The assemble function is used to convert the circuit described in resultdict. See DictionaryAssembler for an example implementation. :param resultdict: The dictionary representing the desired circuit. It is expected to contain the entries "stucture" and "parameters". It may contain other entries. :returns: A string representing the converted circuit code. :rtype: str .. py:function:: flatten_intermediate(intermediate) This is a helper function for working with the intermediate tuple language that is output by the assemble method of QuantumStep objects. .. py:data:: assemblydict_qiskit .. py:data:: assemblydict_openqasm .. py:data:: assemblydict_ibmopenqasm .. py:data:: assemblydict_qutrit .. py:data:: ASSEMBLER_QISKIT .. py:data:: ASSEMBLER_OPENQASM .. py:data:: ASSEMBLER_IBMOPENQASM .. py:data:: ASSEMBLER_QUTRIT