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"

UnsupportedMeasurementAxisError

Bases: Exception

Source code in opensquirrel/passes/exporter/cqasmv1_exporter.py
class UnsupportedMeasurementAxisError(Exception):
    def __init__(self, axis: Axis, *args: Any) -> None:
        """Init of the ``UnsupportedMeasurementAxisError``.

        Args:
            axis: Measurement axis that is not supported.
        """
        nx, ny, nz = (repr_round(component) for component in axis.value)
        super().__init__(f"unsupported measurement axis ({nx}, {ny}, {nz})", *args)

__init__

__init__(axis: Axis, *args: Any) -> None

Init of the UnsupportedMeasurementAxisError.

Parameters:

Name Type Description Default
axis Axis

Measurement axis that is not supported.

required
Source code in opensquirrel/passes/exporter/cqasmv1_exporter.py
def __init__(self, axis: Axis, *args: Any) -> None:
    """Init of the ``UnsupportedMeasurementAxisError``.

    Args:
        axis: Measurement axis that is not supported.
    """
    nx, ny, nz = (repr_round(component) for component in axis.value)
    super().__init__(f"unsupported measurement axis ({nx}, {ny}, {nz})", *args)