<commit_before># Copyright 2016 by Raytheon BBN Technologies Corp.  All Rights Reserved.
'''
Variant of test_Sequences.py that uses the QGL2 compiled versions of the basic sequences, instead of the 
built-in versions.

Requires python3 anaconda, cppy, atom 1.0.0, latest QGL repo, and the latest
JSONLibraryUtils repo cloned as a sub-dir to QGL.
E.G.
pip install cppy; pip install
git+https://github.com/nucleic/atom.git@1.0.0-dev
git clone <QGL>
cd QGL
git clone <JSONLibraryUtils>

You MUST write the QGL2 versions of your classes into a QGL2 module on the pythonpath, such that

   from qgl2.basic_sequences import *

re-defines all the QGL1 functions that you are trying to replace.

You will need both QGL1 and QGL2 on your pythonpath. Put QGL2 first.

The functions to replace are those that are used in test_Sequences, which are not primitives. Mostly this is therefore
the functions in BasicSequences.

These are the functions that I think we do want to redefine

funcs = ["AllXY", "PiRabi", "EchoCRLen", "EchoCRPhase", "HahnEcho", "CPMG", "FlipFlop", "InversionRecovery", "Ramsey", "SPAM", "RabiAmp", "RabiWidth", "RabiAmp_NQubits", "RabiAmpPi", "SingleShot", "PulsedSpec", "SingleQubitRB", "create_RB_seqs", "TwoQubitRB", "SimultaneousRB_AC"]
'''

import tests.test_Sequences

import sys
import unittest

# NOTE: Assuming anything defined in PulsePrimitives we do not need to redo / separately test
# Note that CNOT_CR is potentially multiple pulses so might want to do that one in QGL2

#import QGL2AC as AC
#import QGL2ZX90_CR as ZX90_CR
#import QGL2CNOT_CR as CNOT_CR


#from qgl2.qgl2 import *
from qgl2.qgl2 import concur, qgl2decl, qgl2main
from qgl2.qgl2 import classical, pulse, qbit, qbit_list
from qgl2.qgl2 import Qbit

if __name__ == "__main__":
    try:
        from qgl2.basic_sequences import *
        print("Re-defined basic sequences from qgl2.basic_sequences")
    except Exception as e:
        sys.exit("Failed to redefine sequences from qgl2.basic_sequences: %s" % e)

    # Now must redefine all the methods here.
    # I'd like to do something like this:
#    import QGL2
#    for symbol in dir(QGL2):
#        if symbol[0] == "_" or "QGL1" == symbol[:4]:
#            continue
#        tests.test_Sequences.symbol = symbol

    # But that doesn't quite work. So instead, this uglier version

    try:
        tests.test_Sequences.AllXY = AllXY
        print("Redefined AllXY from QGL2")<commit_msg>show more on import errors, update comment<commit_after># Copyright 2016 by <NAME> Technologies Corp.  All Rights Reserved.
'''
Variant of test_Sequences.py that uses the QGL2 compiled versions of the basic sequences, instead of the 
built-in versions.

Requires python3 anaconda, cppy, atom 1.0.0, latest QGL repo, and the latest
JSONLibraryUtils repo cloned as a sub-dir to QGL (if use the
--recurse-submodules arg when cloning QGL, you get it for free).
E.G.
pip install cppy; pip install
git+https://github.com/nucleic/atom.git@1.0.0-dev
git clone <QGL>
cd QGL
git submodule update, or git clone <JSONLibraryUtils>

You MUST write the QGL2 versions of your classes into a QGL2 module on the pythonpath, such that

   from qgl2.basic_sequences import *

re-defines all the QGL1 functions that you are trying to replace.

You will need both QGL1 and QGL2 on your pythonpath. Put QGL2 first.

The functions to replace are those that are used in test_Sequences, which are not primitives. Mostly this is therefore
the functions in BasicSequences.

These are the functions that I think we do want to redefine

funcs = ["AllXY", "PiRabi", "EchoCRLen", "EchoCRPhase", "HahnEcho", "CPMG", "FlipFlop", "InversionRecovery", "Ramsey", "SPAM", "RabiAmp", "RabiWidth", "RabiAmp_NQubits", "RabiAmpPi", "SingleShot", "PulsedSpec", "SingleQubitRB", "create_RB_seqs", "TwoQubitRB", "SimultaneousRB_AC"]
'''

import tests.test_Sequences

import sys
import unittest

# NOTE: Assuming anything defined in PulsePrimitives we do not need to redo / separately test
# Note that CNOT_CR is potentially multiple pulses so might want to do that one in QGL2

#import QGL2AC as AC
#import QGL2ZX90_CR as ZX90_CR
#import QGL2CNOT_CR as CNOT_CR


#from qgl2.qgl2 import *
from qgl2.qgl2 import concur, qgl2decl, qgl2main
from qgl2.qgl2 import classical, pulse, qbit, qbit_list
from qgl2.qgl2 import Qbit

if __name__ == "__main__":
    try:
        from qgl2.basic_sequences import *
        print("Re-defined basic sequences from qgl2.basic_sequences")
    except Exception as e:
        import traceback
        sys.exit("Failed to redefine sequences from qgl2.basic_sequences: %s. %s" % (e, traceback.format_exc()))

    # Now must redefine all the methods here.
    # I'd like to do something like this:
#    import QGL2
#    for symbol in dir(QGL2):
#        if symbol[0] == "_" or "QGL1" == symbol[:4]:
#            continue
#        tests.test_Sequences.symbol = symbol

    # But that doesn't quite work. So instead, this uglier version

    try:
        tests.test_Sequences.AllXY = AllXY
        print("Redefined AllXY from QGL2")
{'fraction_non_alphanumeric': 0.08285431119920714, 'fraction_numerical': 0.01823587710604559, 'mean_word_length': 3.9763313609467454, 'pattern_counts': {'":': 2, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, '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': '2543720', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1646, 'n_words': 629}