<commit_before># Copyright 2016 by <NAME> Corp.  All Rights Reserved.

# Tests for end to end Edge handling, and handling stubs on >1 qubits

from qgl2.qgl1 import QubitFactory, Id, X, MEAS, Y, echoCR, CNOT_CR
from qgl2.qgl2 import qgl2decl, sequence, concur, seq, qbit, qgl2stub
from qgl2.util import init

@qgl2decl
def edgeTest() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
    with concur:
        for q in [q1, q2]:
            X(q)
    echoCR(q1, q2)

# Simples possible test
@qgl2decl
def edgeTest2() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    echoCR(q1, q2)

@qgl2decl
def edgeTest3() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
    echoCR(q1, q2)
    X(q2)
    Y(q2)
    Id(q2)
    X(q2)

# Note you need a 2nd edge from q2 to q1 for edgeTest4,
# which may not be realistic
@qgl2decl
def edgeTest4() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')

    with concur:
        for q in [q1, q2]:
            init(q)
    echoCR(q1, q2)
    echoCR(q2, q1)
    echoCR(q1, q2)
    X(q1)
    Y(q1)
    Id(q1)
    X(q1)

# edgeTest5 involves a stub that
# is bad: creating and using another / different qubit
# Here we have a stub whose implementation is in this same file
@qgl2stub('pyqgl2.test.edge', 'MyPulseReal')
def MyPulse(source: qbit) -> qbit:
    pass

# QGL1 function
def MyPulseReal(source):
    from QGL.PulsePrimitives import X
    from QGL.ChannelLibrary import QubitFactory
    q3 = QubitFactory('q3')
    return X(q3)

@qgl2decl
def edgeTest5() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
            MyPulse(q)

@qgl2decl
def cnotcrTest() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
    CNOT_CR(q1, q2)
<commit_msg>typo in comment<commit_after># Copyright 2016 by <NAME>.  All Rights Reserved.

# Tests for end to end Edge handling, and handling stubs on >1 qubits

from qgl2.qgl1 import QubitFactory, Id, X, MEAS, Y, echoCR, CNOT_CR
from qgl2.qgl2 import qgl2decl, sequence, concur, seq, qbit, qgl2stub
from qgl2.util import init

@qgl2decl
def edgeTest() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
    with concur:
        for q in [q1, q2]:
            X(q)
    echoCR(q1, q2)

# Simplest possible test
@qgl2decl
def edgeTest2() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    echoCR(q1, q2)

@qgl2decl
def edgeTest3() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
    echoCR(q1, q2)
    X(q2)
    Y(q2)
    Id(q2)
    X(q2)

# Note you need a 2nd edge from q2 to q1 for edgeTest4,
# which may not be realistic
@qgl2decl
def edgeTest4() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')

    with concur:
        for q in [q1, q2]:
            init(q)
    echoCR(q1, q2)
    echoCR(q2, q1)
    echoCR(q1, q2)
    X(q1)
    Y(q1)
    Id(q1)
    X(q1)

# edgeTest5 involves a stub that
# is bad: creating and using another / different qubit
# Here we have a stub whose implementation is in this same file
@qgl2stub('pyqgl2.test.edge', 'MyPulseReal')
def MyPulse(source: qbit) -> qbit:
    pass

# QGL1 function
def MyPulseReal(source):
    from QGL.PulsePrimitives import X
    from QGL.ChannelLibrary import QubitFactory
    q3 = QubitFactory('q3')
    return X(q3)

@qgl2decl
def edgeTest5() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
            MyPulse(q)

@qgl2decl
def cnotcrTest() -> sequence:
    q1 = QubitFactory('q1')
    q2 = QubitFactory('q2')
    with concur:
        for q in [q1, q2]:
            init(q)
    CNOT_CR(q1, q2)

{'fraction_non_alphanumeric': 0.11770475723393821, 'fraction_numerical': 0.04462972045120157, 'mean_word_length': 2.5469565217391303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5754310', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1636, 'n_words': 465}