Esempio n. 1
0
def FENCE(*qubits: Union[int, Qubit, FormalArgument]) -> Union[FenceAll, Fence]:
    """
    Produce a FENCE instruction.

    Note: If no qubits are specified, then this is interpreted as a global FENCE.

    :params qubits: A list of qubits or formal arguments.
    :returns: A Fence or FenceAll instance.
    """
    if qubits:
        return Fence([Qubit(t) if isinstance(t, int) else t for t in qubits])
    else:
        return FenceAll()
Esempio n. 2
0
 def fence_some(self, qubits):
     f = Fence(list(qubits))
     return f
Esempio n. 3
0
def test_parsing_fence():
    parse_equals("FENCE 0", Fence([Qubit(0)]))
    parse_equals("FENCE 0 1", Fence([Qubit(0), Qubit(1)]))
    parse_equals("FENCE q s", Fence([FormalArgument("q"),
                                     FormalArgument("s")]))
    parse_equals("FENCE", FenceAll())