How to use the pygsti.objects.circuit.Circuit function in pyGSTi

To help you get started, we’ve selected a few pyGSTi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BBN-Q / QGL / QGL / GSTTools.py View on Github external
"""
    Helper function that takes an arbitrarily nested list of pygsti gatestrings
    and converts them into QGL sequences, keeping the same nesting of lists.

    Inputs:
        gst_list: GateString to convert, or possibly nested list of pyGSTi GateStrings.
        qubit: QGL qubit to apply the sequence to
        qgl_map: Dictionary that maps between pyGSTi "Gx" string to QGL pulse
        append_meas: Append a measurement to each sequence.
    Returns:
        QGL sequences, preserving the input list nesting (as a generator)
    """
    if isinstance(gst_list, Circuit):
        gst_list = [gst_list]
    for item in gst_list:
        if isinstance(item, Circuit):
            mapped = map(lambda x: qgl_map[str(x)](qubit), item.tup)
            if append_meas:
                yield list(chain(mapped, [MEAS(qubit)]))
            else:
                yield list(mapped)
        elif isinstance(item, list):
            yield list(gst_map_1Q(item, qubit, qgl_map=qgl_map, append_meas=append_meas))
github BBN-Q / QGL / QGL / GSTTools.py View on Github external
def gst_map_1Q(gst_list, qubit, qgl_map=gst_gate_map, append_meas=True):
    """
    Helper function that takes an arbitrarily nested list of pygsti gatestrings
    and converts them into QGL sequences, keeping the same nesting of lists.

    Inputs:
        gst_list: GateString to convert, or possibly nested list of pyGSTi GateStrings.
        qubit: QGL qubit to apply the sequence to
        qgl_map: Dictionary that maps between pyGSTi "Gx" string to QGL pulse
        append_meas: Append a measurement to each sequence.
    Returns:
        QGL sequences, preserving the input list nesting (as a generator)
    """
    if isinstance(gst_list, Circuit):
        gst_list = [gst_list]
    for item in gst_list:
        if isinstance(item, Circuit):
            mapped = map(lambda x: qgl_map[str(x)](qubit), item.tup)
            if append_meas:
                yield list(chain(mapped, [MEAS(qubit)]))
            else:
                yield list(mapped)
        elif isinstance(item, list):
            yield list(gst_map_1Q(item, qubit, qgl_map=qgl_map, append_meas=append_meas))