<commit_before># -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by ExopyHqcLegacy Authors, see AUTHORS for more details.
#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Test the capabilities of the AWG5014Context.

"""
from collections import OrderedDict

import enaml
import numpy as np

from exopy.testing.util import show_and_close_widget

from exopy_pulses.pulses.sequences.base_sequences import (RootSequence,
                                                          BaseSequence)
from exopy_pulses.pulses.pulse import Pulse
from exopy_pulses.pulses.shapes.square_shape import SquareShape
from exopy_pulses.pulses.shapes.modulation import Modulation

from exopy_hqc_legacy.pulses.contexts.awg_context import (AWG5014Context,
                                                          to_bytes)
with enaml.imports():
    from exopy_hqc_legacy.pulses.contexts.views.awg_context_view\
        import AWG5014ContextView


class DummyChannel(object):
    """Dummy AWG channel.

    """
    def __init__(self, driver, index):
        self.array = None
        self.output_state = 'OFF'
        self._driver = driver
        self._index = index

    def select_sequence(self, seq_name):
        self.array = self._driver.sequences[seq_name]

    def clear_sequence(self):
        self.array = None


class DummyDriver(object):
    """Dummy AWG5014Driver used for testing purposes.

    """
    def __init__(self):
        self.sequences = {}
        self.defined_channels = [1, 2, 3, 4]
        self.channels = {i: DummyChannel(self, i) for i in range(1, 5)}
        self.set_running(False)

    def to_send(self, name, array):
        self.sequences[name] = array

    def get_channel(self, ch_id):
        return self.channels[ch_id]


class TestAWGContext(object):
    """Test the AWG5014 context capabilities.

    """
    def setup(self):
        self.root = RootSequence()
        self.context = AWG5014Context(sequence_name='Test')
        self.compile = self.context.compile_and_transfer_sequence
        self.driver = DummyDriver()
        self.root.context = self.context

    def test_changing_unit(self):
        time = self.context.sampling_time
        self.context.time_unit = 'ms'
        assert self.context.sampling_time != time

    def test_compiling_A_pulse_not_selecting(self):
        self.context.select_after_transfer = False
        self.context.run_after_transfer = False
        self.root.time_constrained = True<commit_msg>Try to pass tests<commit_after># -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by ExopyHqcLegacy Authors, see AUTHORS for more details.
#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Test the capabilities of the AWG5014Context.

"""
from collections import OrderedDict

import enaml
import numpy as np

from exopy.testing.util import show_and_close_widget

from exopy_pulses.pulses.sequences.base_sequences import (RootSequence,
                                                          BaseSequence)
from exopy_pulses.pulses.pulse import Pulse
from exopy_pulses.pulses.shapes.square_shape import SquareShape
from exopy_pulses.pulses.shapes.modulation import Modulation

from exopy_hqc_legacy.pulses.contexts.awg_context import (AWG5014Context,
                                                          to_bytes)
with enaml.imports():
    from exopy_hqc_legacy.pulses.contexts.views.awg_context_view\
        import AWG5014ContextView


class DummyChannel(object):
    """Dummy AWG channel.

    """
    def __init__(self, driver, index):
        self.array = None
        self.output_state = 'OFF'
        self._driver = driver
        self._index = index

    def select_sequence(self, seq_name):
        self.array = self._driver.sequences[seq_name]

    def clear_sequence(self):
        self.array = None


class DummyDriver(object):
    """Dummy AWG5014Driver used for testing purposes.

    """
    def __init__(self):
        self.sequences = {}
        self.defined_channels = [1, 2, 3, 4]
        self.channels = {i: DummyChannel(self, i) for i in range(1, 5)}
        self.running = False

    def to_send(self, name, array):
        self.sequences[name] = array

    def get_channel(self, ch_id):
        return self.channels[ch_id]


class TestAWGContext(object):
    """Test the AWG5014 context capabilities.

    """
    def setup(self):
        self.root = RootSequence()
        self.context = AWG5014Context(sequence_name='Test')
        self.compile = self.context.compile_and_transfer_sequence
        self.driver = DummyDriver()
        self.root.context = self.context

    def test_changing_unit(self):
        time = self.context.sampling_time
        self.context.time_unit = 'ms'
        assert self.context.sampling_time != time

    def test_compiling_A_pulse_not_selecting(self):
        self.context.select_after_transfer = False
        self.context.run_after_transfer = False
        self.root.time_constrained = True
{'fraction_non_alphanumeric': 0.13877020248931823, 'fraction_numerical': 0.014490061304105517, 'mean_word_length': 2.223952095808383, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1678226', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1476, 'n_words': 363}