<commit_before>import array

class BaseNetwork(object):

    def __init__(self):
        self.elements = []
        self.data = array.array('B',())
        self.max_chan = 0

    def init_data(self):
        for l in self.elements:
            for c in l.channels:
                # TODO max_chan is wrong here - is enforcement needed yet?
                max_chan = max(self.max_chan, c)
        self.data.extend([0 for i in range(max_chan)])

    def blackout(self):
        # @@ todo
        pass

    def reset(self):
        self.data = array.array('B', (0,) * len(self.data))

    def update(self,show):
        for e in self.elements:
            e.update(show)

    def add_element(self, element):
        if element not in self.elements:
            self.elements.append(element)
            return True
        return False
        # element.network=self? will this ever be needed?

    def get_named_element(self,name):
        for l in self.elements:
            # @@ should this be case insensitive?
            if l.name.lower() == name.lower():
                return l
        return False

    def add_elements(self,lights):
        for l in lights:
            self.add_element(l)


    def update_data(self):
        [e.update_data(self.data) for e in self.elements]

    def send_data(self):
        raise NotImplementedError

class DefaultNetwork(BaseNetwork):
    def __init__(self):
        super(DefaultNetwork, self).__init__()

    def send_data(self):
        # this class sends no data, only manages higher level objects
        pass
<commit_msg>fix off by 1 for DMX and data array<commit_after>import array

class BaseNetwork(object):

    def __init__(self):
        self.elements = []
        self.data = array.array('B',())
        self.max_chan = 0

    def init_data(self):
        for l in self.elements:
            for c in l.channels:
                max_chan = max(self.max_chan, c + 1)
        self.data.extend([0 for i in range(max_chan)])

    def blackout(self):
        # @@ todo
        pass

    def reset(self):
        self.data = array.array('B', (0,) * len(self.data))

    def update(self,show):
        for e in self.elements:
            e.update(show)

    def add_element(self, element):
        if element not in self.elements:
            self.elements.append(element)
            return True
        return False
        # element.network=self? will this ever be needed?

    def get_named_element(self,name):
        for l in self.elements:
            # @@ should this be case insensitive?
            if l.name.lower() == name.lower():
                return l
        return False

    def add_elements(self,lights):
        for l in lights:
            self.add_element(l)


    def update_data(self):
        [e.update_data(self.data) for e in self.elements]

    def send_data(self):
        raise NotImplementedError

class DefaultNetwork(BaseNetwork):
    def __init__(self):
        super(DefaultNetwork, self).__init__()

    def send_data(self):
        # this class sends no data, only manages higher level objects
        pass

{'fraction_non_alphanumeric': 0.09874152952565343, 'fraction_numerical': 0.0025814778960955146, 'mean_word_length': 1.9893924783027965, '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': '1322544', 'n_tokens_mistral': 923, 'n_tokens_neox': 879, 'n_words': 258}