<commit_before>import time
import numpy as np
import platform
from os import path as op
from functools import partial
if 'Windows' in platform.platform():
    try:
        from tdt.util import connect_rpcox, connect_zbus
    except ImportError:
        connect_rpcox, connect_zbus = None, None  # analysis:ignore
else:
    connect_rpcox, connect_zbus = None, None


from ._utils import get_config, wait_secs, logger
from ._input_controllers import Keyboard


def _dummy_fun(self, name, ret, *args, **kwargs):
    logger.info('dummy-tdt: {0} {1}'.format(name, str(args)[:20] + ' ... ' +
                                            str(kwargs)[:20] + ' ...'))
    return ret


class DummyRPcoX(object):
    def __init__(self, model, interface):
        self.model = model
        self.interface = interface
        names = ['LoadCOF', 'ClearCOF', 'Run', 'ZeroTag', 'SetTagVal',
                 'GetSFreq', 'GetTagV', 'WriteTagV', 'Halt', 'SoftTrg']
        returns = [True, True, True, True, True,
                   24414.0125, 0.0, True, True, True]
        for name, ret in zip(names, returns):
            setattr(self, name, partial(_dummy_fun, self, name, ret))


class TDTController(Keyboard):
    """Interface for TDT audio output, stamping, and responses

    Parameters
    ----------
    tdt_params : dict | None
        A dictionary containing keys:
        'TYPE' (this should always be 'tdt');
        'TDT_MODEL' (String name of the TDT model ('RM1', 'RP2', etc));
        'TDT_CIRCUIT_PATH' (Path to the TDT circuit); and
        'TDT_INTERFACE' (Type of connection, either 'USB' or 'GB').

    Returns
    -------
    tdt_obj : instance of a TDTObject.
        The object containing all relevant info about the TDT in use.
    """
    def __init__(self, tdt_params):
        legal_keys = ['TYPE', 'TDT_MODEL', 'TDT_CIRCUIT_PATH', 'TDT_INTERFACE',<commit_msg>FIX: Fix dummy TDT<commit_after>import time
import numpy as np
import platform
from os import path as op
from functools import partial
if 'Windows' in platform.platform():
    try:
        from tdt.util import connect_rpcox, connect_zbus
    except ImportError:
        connect_rpcox, connect_zbus = None, None  # analysis:ignore
else:
    connect_rpcox, connect_zbus = None, None


from ._utils import get_config, wait_secs, logger, ZeroClock
from ._input_controllers import Keyboard


def _dummy_fun(self, name, ret, *args, **kwargs):
    logger.info('dummy-tdt: {0} {1}'.format(name, str(args)[:20] + ' ... ' +
                                            str(kwargs)[:20] + ' ...'))
    return ret


class DummyRPcoX(object):
    def __init__(self, model, interface):
        self.model = model
        self.interface = interface
        names = ['LoadCOF', 'ClearCOF', 'Run', 'ZeroTag', 'SetTagVal',
                 'GetSFreq', 'GetTagV', 'WriteTagV', 'Halt', 'SoftTrg']
        returns = [True, True, True, True, True,
                   24414.0125, 0.0, True, True, True]
        for name, ret in zip(names, returns):
            setattr(self, name, partial(_dummy_fun, self, name, ret))
        self._clock = ZeroClock()

    def GetTagVal(self, name):
        if name == 'masterclock':
            return self._clock.get_time()
        elif name == 'npressabs':
            return 0
        else:
            raise ValueError('unknown tag "{0}"'.format(name))


class TDTController(Keyboard):
    """Interface for TDT audio output, stamping, and responses

    Parameters
    ----------
    tdt_params : dict | None
        A dictionary containing keys:
        'TYPE' (this should always be 'tdt');
        'TDT_MODEL' (String name of the TDT model ('RM1', 'RP2', etc));
        'TDT_CIRCUIT_PATH' (Path to the TDT circuit); and
        'TDT_INTERFACE' (Type of connection, either 'USB' or 'GB').

    Returns
    -------
    tdt_obj : instance of a TDTObject.
        The object containing all relevant info about the TDT in use.
    """
    def __init__(self, tdt_params):
        legal_keys = ['TYPE', 'TDT_MODEL', 'TDT_CIRCUIT_PATH', 'TDT_INTERFACE',
{'fraction_non_alphanumeric': 0.12431896978702328, 'fraction_numerical': 0.009905894006934125, 'mean_word_length': 2.5648720211827007, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7217754', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1234, 'n_words': 385}