<commit_before># -*- coding: utf-8 -*-


class RangeError(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)


class QCL(object):
    """Simple python wrapper for a selection of serial port commands to control a daylight solution tunable QCL.



    """
    _wn_range      = (980.04, 1244.99)
    _freq_range    = (1.0, 100.0)
    _pw_range      = (0.04, 0.5)
    _startwn_range = (980.04, 1244.99)
    _stopwn_range  = (980.04, 1244.99)
    _rate_range    = (1.0, 6.0)
    _cycles_range    = (1.0, 10000.0)
    _mode_range    = (1.0, 4.0)
    _pause_range   = (0.0, 10.0)
    _step_range    = (0.01, 264.95)

    def __init__(self, port=0, log=False):
        import serial
        super(QCL, self).__init__()
        self.ser = serial.Serial(port)      # opens the COM1 port to communicate with the laser
        self.ser.baudrate = 115200       # set the baudrate to 115200 to use the right speed to send data over
        self.ser.timeout = 1             # set timeout for port to 1 second
        self.log = log
        self.log_file = []
        self.get_all()

    def _log_write(self, string):
        if self.log is True:
            self.log_file.append(str(string))
        else:
            pass

    def get_wn(self):
        """get the current wavenumber"""
        command = ":laser:set?\n"
        self._log_write(command)
        self.ser.write(command)<commit_msg>testing the use of namedtuzples to create the option to call commands in the form of qcl.Set/Get.wn() and the range in form of qcl._range.wn()<commit_after># -*- coding: utf-8 -*-


class RangeError(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)


class QCL(object):
    """Simple python wrapper for a selection of serial port commands to control a daylight solution tunable QCL.



    """
    from collections import namedtuple
    _control = namedtuple("control", ["wn", "freq", "pw", "startwn", "stopwn", "rate", "cycles", "mode", "pause", "step"])
    Range = _control(wn=(980.04, 1244.99), freq=(1.0, 100.0), pw=(0.04, 0.5), startwn=(980.04, 1244.99), stopwn=(980.04, 1244.99), rate=(1.0, 6.0), cycles=(1.0, 10000.0), mode=(1.0, 4.0), pause=(0.0, 10.0), step=(0.01, 264.95))

    def __init__(self, port=0, log=False):
        import serial
        super(QCL, self).__init__()
        self.ser = serial.Serial(port)      # opens the COM1 port to communicate with the laser
        self.ser.baudrate = 115200       # set the baudrate to 115200 to use the right speed to send data over
        self.ser.timeout = 1             # set timeout for port to 1 second
        self.log = log
        self.log_file = []
        self.get_all()
        Set = self._control(wn=self.set_wn, freq=self.set_freq, pw=self.set_pw, startwn=self.set_startwn, stopwn=self.set_stopwn, rate=self.set_rate, cycles=self.set_cycles, mode=self.set_mode, pause=self.set_pause, step=self.set_step)

    def _log_write(self, string):
        if self.log is True:
            self.log_file.append(str(string))
        else:
            pass

    def get_wn(self):
        """get the current wavenumber"""
        command = ":laser:set?\n"
        self._log_write(command)
        self.ser.write(command)
{'fraction_non_alphanumeric': 0.12945081472540737, 'fraction_numerical': 0.05431502715751358, 'mean_word_length': 2.435233160621762, 'pattern_counts': {'":': 2, '<': 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': '760934', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1102, 'n_words': 302}