Skip to content

cqasmv1_exporter

CqasmV1Exporter

Bases: Exporter

Source code in opensquirrel/passes/exporter/cqasmv1_exporter.py
class CqasmV1Exporter(Exporter):
    def __init__(self, **kwargs: Any) -> None:
        super().__init__(**kwargs)

    def export(self, circuit: Circuit) -> str:
        """Exports the given circuit to the [cQASM v1](https://libqasm.readthedocs.io/en/latest/index.html)
        format.

        Args:
            circuit (Circuit): The quantum circuit to export.

        Returns:
            The [cQASM v1](https://libqasm.readthedocs.io/en/latest/index.html) representation of the circuit.

        """
        cqasmv1_creator = _CQASMv1Creator(circuit.register_manager)

        circuit.ir.accept(cqasmv1_creator)

        return _post_process(cqasmv1_creator.output).rstrip() + "\n"

export

export(circuit: Circuit) -> str

Exports the given circuit to the cQASM v1 format.

Parameters:

Name Type Description Default
circuit Circuit

The quantum circuit to export.

required

Returns:

Type Description
str

The cQASM v1 representation of the circuit.

Source code in opensquirrel/passes/exporter/cqasmv1_exporter.py
def export(self, circuit: Circuit) -> str:
    """Exports the given circuit to the [cQASM v1](https://libqasm.readthedocs.io/en/latest/index.html)
    format.

    Args:
        circuit (Circuit): The quantum circuit to export.

    Returns:
        The [cQASM v1](https://libqasm.readthedocs.io/en/latest/index.html) representation of the circuit.

    """
    cqasmv1_creator = _CQASMv1Creator(circuit.register_manager)

    circuit.ir.accept(cqasmv1_creator)

    return _post_process(cqasmv1_creator.output).rstrip() + "\n"