<commit_before>from itertools import product

from qgl2.qgl2 import concur, qgl2decl, qgl2main
from qgl2.qgl2 import classical, pulse, qbit, qbit_list
from qgl2.qgl1 import QubitFactory, Id, X90, Y90, X, Y, MEAS

# Don't do this import here - it replaces our stubs above
#from QGL import *

# Note this different / non-standard definition of init
# Elsewhere init takes a single qubit
def init(*args):
    pass

@qgl2decl
def tomo(f, q1:qbit, q2:qbit):
    # QGL2 can't yet handle a variable that is a list of functions
    fncs = [Id, X90, Y90, X]
    # QGL2 can't yet handle this call to product() to produce the list of functions to call
    for prep in product(fncs, fncs):
        for meas in product(fncs, fncs):
            init(q1, q2)
            with concur:
                for p, q in zip(prep, (q1,q2)):
                    p(q)
            f(q1, q2)
            with concur:
                for m, q in zip(meas, (q1, q2)):
                    m(q)
                    MEAS(q)

@qgl2decl
def tomo_no_generators(f, q1:qbit, q2:qbit):
    # QGL2 can't yet handle a variable that is a list of functions
    fncs = [Id, X90, Y90, X]
    # QGL2 can't yet handle this call to product() to produce the list of functions to call
    for prep in list(product(fncs, fncs)):
        for meas in list(product(fncs, fncs)):
            with concur:
                for p, q in list(zip(prep, (q1,q2))):
                    p(q)
            f(q1, q2)
            with concur:
                for m, q in list(zip(meas, (q1, q2))):
                    m(q)<commit_msg>update comment about generators; they work now<commit_after>from itertools import product

from qgl2.qgl2 import concur, qgl2decl, qgl2main
from qgl2.qgl2 import classical, pulse, qbit, qbit_list
from qgl2.qgl1 import QubitFactory, Id, X90, Y90, X, Y, MEAS

# Don't do this import here - it replaces our stubs above
#from QGL import *

# Note this different / non-standard definition of init
# Elsewhere init takes a single qubit
def init(*args):
    pass

@qgl2decl
def tomo(f, q1:qbit, q2:qbit):
    # QGL2 can't yet handle a variable that is a list of functions
    fncs = [Id, X90, Y90, X]
    for prep in product(fncs, fncs):
        for meas in product(fncs, fncs):
            init(q1, q2)
            with concur:
                for p, q in zip(prep, (q1,q2)):
                    p(q)
            f(q1, q2)
            with concur:
                for m, q in zip(meas, (q1, q2)):
                    m(q)
                    MEAS(q)

@qgl2decl
def tomo_no_generators(f, q1:qbit, q2:qbit):
    # QGL2 can't yet handle a variable that is a list of functions
    fncs = [Id, X90, Y90, X]
    # QGL2 couldn't handle generators and needed to listify them
    # (no longer true)
    for prep in list(product(fncs, fncs)):
        for meas in list(product(fncs, fncs)):
            with concur:
                for p, q in list(zip(prep, (q1,q2))):
                    p(q)
            f(q1, q2)
            with concur:
                for m, q in list(zip(meas, (q1, q2))):
                    m(q)
{'fraction_non_alphanumeric': 0.0963855421686747, 'fraction_numerical': 0.02832953435363074, 'mean_word_length': 1.9970731707317073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1410475', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1036, 'n_words': 379}