<commit_before>import unittest
import tempfile
from os.path import join
from os import makedirs

from pycqed.instrument_drivers.physical_instruments.Transport import FileTransport
from pycqed.instrument_drivers.physical_instruments.QuTechCC import QuTechCC


class Test_QutechCC(unittest.TestCase):
    def test_all(self):
        fn = 'Test_QutechCC_test_all.scpi.txt'
        test_path = join('test_output',fn)
        makedirs('test_output', exist_ok=True)

        transport = FileTransport(test_path)
        cc = QuTechCC('cc', transport)

        cc.reset()
        cc.clear_status()
        cc.set_status_questionable_frequency_enable(0x7FFF)

        cc.dio0_out_delay(0)
        cc.dio0_out_delay(31)
        cc.dio8_out_delay(0)
        cc.dio8_out_delay(31)

        cc.vsm_channel_delay0(0)
        cc.vsm_channel_delay0(1)
        cc.vsm_channel_delay0(127)
        cc.vsm_channel_delay31(0)
        cc.vsm_channel_delay31(127)

        cc.vsm_rise_delay0(0)
        cc.vsm_rise_delay0(48)
        cc.vsm_rise_delay31(0)
        cc.vsm_rise_delay31(48)
        cc.vsm_fall_delay0(0)
        cc.vsm_fall_delay0(48)
        cc.vsm_fall_delay31(0)
        cc.vsm_fall_delay31(48)

        cc.debug_marker_in(0, cc.UHFQA_TRIG)
        cc.debug_marker_in(0, cc.UHFQA_CW[0])

        cc.debug_marker_out(0, cc.UHFQA_TRIG)
        cc.debug_marker_out(8, cc.HDAWG_TRIG)

        prog = '    stop\n'
        cc.sequence_program(prog)

        tmp_file = tempfile.NamedTemporaryFile(mode='w', delete=False)
        tmp_file.write(prog)
        tmp_file_name = tmp_file.name
        tmp_file.close()  # to allow access to file
        cc.eqasm_program(tmp_file.name)
        cc.start()
        cc.stop()

        transport.close()  # to allow access to file

        # check results
        test_output = open(test_path).read()
        golden = open(join('golden',fn)).read()<commit_msg>cleanup<commit_after>import unittest
import tempfile
import os

from pycqed.instrument_drivers.physical_instruments.Transport import FileTransport
from pycqed.instrument_drivers.physical_instruments.QuTechCC import QuTechCC


class Test_QutechCC(unittest.TestCase):
    def test_all(self):
        fn = 'Test_QutechCC_test_all.scpi.txt'
        test_path = os.path.join('test_output',fn)
        os.makedirs('test_output', exist_ok=True)

        transport = FileTransport(test_path)
        cc = QuTechCC('cc', transport)

        cc.reset()
        cc.clear_status()
        cc.set_status_questionable_frequency_enable(0x7FFF)

        cc.dio0_out_delay(0)
        cc.dio0_out_delay(31)
        cc.dio8_out_delay(0)
        cc.dio8_out_delay(31)

        cc.vsm_channel_delay0(0)
        cc.vsm_channel_delay0(1)
        cc.vsm_channel_delay0(127)
        cc.vsm_channel_delay31(0)
        cc.vsm_channel_delay31(127)

        cc.vsm_rise_delay0(0)
        cc.vsm_rise_delay0(48)
        cc.vsm_rise_delay31(0)
        cc.vsm_rise_delay31(48)
        cc.vsm_fall_delay0(0)
        cc.vsm_fall_delay0(48)
        cc.vsm_fall_delay31(0)
        cc.vsm_fall_delay31(48)

        cc.debug_marker_in(0, cc.UHFQA_TRIG)
        cc.debug_marker_in(0, cc.UHFQA_CW[0])

        cc.debug_marker_out(0, cc.UHFQA_TRIG)
        cc.debug_marker_out(8, cc.HDAWG_TRIG)

        prog = '    stop\n'
        cc.sequence_program(prog)

        tmp_file = tempfile.NamedTemporaryFile(mode='w', delete=False)
        tmp_file.write(prog)
        tmp_file.close()  # to allow access to file
        cc.eqasm_program(tmp_file.name)
        os.unlink(tmp_file.name)

        cc.start()
        cc.stop()

        transport.close()  # to allow access to file

        # check results
        test_output = open(test_path).read()
        golden = open(os.path.join('golden',fn)).read()
{'fraction_non_alphanumeric': 0.09866666666666667, 'fraction_numerical': 0.0304, 'mean_word_length': 2.6452866861030127, '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': '3957383', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1375, 'n_words': 178}