<commit_before>import liblo
import numpy


class Pattern(object):
    def __init__(self, tracks=8, steps=16):
        self.steps = numpy.zeros((steps, tracks), bool)
        self.muted = numpy.zeros(tracks, bool)

    @property
    def num_tracks(self):
        return self.steps.shape[1]

    @property
    def num_steps(self):
        return self.steps.shape[0]

    def set_step(self, track, step):
        self.steps[step, track] = True

    def clear_step(self, track, step):
        self.steps[step, track] = False

    def mute(self, track):
        self.muted[track] = True

    def unmute(self, track):
        self.muted[track] = False


class SharedPattern(Pattern):
    def __init__(self, address=8765):
        Pattern.__init__(self)
        self.target = liblo.Address(address)

    def set_step(self, track, step):
        if not self.steps[step, track]:
            liblo.send(self.target, '/pattern/set', track, step)
        Pattern.set_step(self, track, step)
<commit_msg>Add print method for patterns<commit_after>import liblo
import numpy


class Pattern(object):
    def __init__(self, tracks=8, steps=16):
        self.steps = numpy.zeros((steps, tracks), bool)
        self.muted = numpy.zeros(tracks, bool)

    @property
    def num_tracks(self):
        return self.steps.shape[1]

    @property
    def num_steps(self):
        return self.steps.shape[0]

    def set_step(self, track, step):
        self.steps[step, track] = True

    def clear_step(self, track, step):
        self.steps[step, track] = False

    def mute(self, track):
        self.muted[track] = True

    def unmute(self, track):
        self.muted[track] = False

    def print_(self):
        for track in range(self.num_tracks):
            for step in range(self.num_steps):
                if self.steps[step, track]:
                    print '*',
                else:
                    print ' ',
            print


class SharedPattern(Pattern):
    def __init__(self, address=8765):
        Pattern.__init__(self)
        self.target = liblo.Address(address)

    def set_step(self, track, step):
        if not self.steps[step, track]:
            liblo.send(self.target, '/pattern/set', track, step)
        Pattern.set_step(self, track, step)

{'fraction_non_alphanumeric': 0.11863656485170429, 'fraction_numerical': 0.00796812749003984, 'mean_word_length': 2.3883058470764618, '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': '1003635', 'n_tokens_mistral': 727, 'n_tokens_neox': 687, 'n_words': 169}