<commit_before>import logging
import copy
from collections import defaultdict
from itertools import chain

from pymachine.src.control import Control
from constants import deep_pre, avm_pre, enc_pre

class Machine(object):
    def __init__(self, name, control=None, part_num=1):
        self.printname_ = name
        self.partitions = [[] for i in range(part_num)]

        self.set_control(control)

        logging.debug(u"{0} created with {1} partitions".format(
            name, len(self.partitions)))

        self.parents = set()

    def __repr__(self):
        return str(self)

    def __str__(self):
        return unicode(self).encode('utf-8')

    def __unicode__(self):
        if self.control is None:
            return u"{0} (no control)".format(self.printname())
        return u"{0} ({1})".format(
            self.printname(),
            self.control.to_debug_str().replace('\n', ' '))

    def __deepcopy__(self, memo):
        new_machine = self.__class__(self.printname_)
        memo[id(self)] = new_machine
        new_partitions = copy.deepcopy(self.partitions, memo)
        new_control = copy.deepcopy(self.control, memo)
        new_machine.partitions = new_partitions
        new_machine.control = new_control

        for part_i, part in enumerate(new_machine.partitions):
            for m in part:
                m.add_parent_link(new_machine, part_i)
        return new_machine

    def unify(self, machine2):
        for i, part in enumerate(machine2.partitions):
            for m in part:
                if m not in self.partitions[i]:
                    self.partitions[i].append(m)
                    m.add_parent_link(self, i)

        for parent, i in machine2.parents:
            parent.partitions[i].remove(machine2)
            parent.partitions[i].append(self)
            self.add_parent_link(parent, i)

    def d_printname(self):
        """printname for dot output"""
        #TODO
        pn = self.printname_.split('/')[0]
        return Machine.d_clean(pn)

    @staticmethod
    def d_clean(string):
        s = string
        for c in ('=', '@', '-', ',', "'", '"'):
            s = s.replace(c, '_')
        if s == 'edge':
            s += '_'
        elif s == '$':
            s = '_dollars'
        return s

    def printname(self):
        return self.printname_
<commit_msg>temp hack to avoid IDs on printnames<commit_after>import logging
import copy
from collections import defaultdict
from itertools import chain

from pymachine.src.control import Control
from constants import deep_pre, avm_pre, enc_pre

class Machine(object):
    def __init__(self, name, control=None, part_num=1):
        self.printname_ = name
        self.partitions = [[] for i in range(part_num)]

        self.set_control(control)

        logging.debug(u"{0} created with {1} partitions".format(
            name, len(self.partitions)))

        self.parents = set()

    def __repr__(self):
        return str(self)

    def __str__(self):
        return unicode(self).encode('utf-8')

    def __unicode__(self):
        if self.control is None:
            return u"{0} (no control)".format(self.printname())
        return u"{0} ({1})".format(
            self.printname(),
            self.control.to_debug_str().replace('\n', ' '))

    def __deepcopy__(self, memo):
        new_machine = self.__class__(self.printname_)
        memo[id(self)] = new_machine
        new_partitions = copy.deepcopy(self.partitions, memo)
        new_control = copy.deepcopy(self.control, memo)
        new_machine.partitions = new_partitions
        new_machine.control = new_control

        for part_i, part in enumerate(new_machine.partitions):
            for m in part:
                m.add_parent_link(new_machine, part_i)
        return new_machine

    def unify(self, machine2):
        for i, part in enumerate(machine2.partitions):
            for m in part:
                if m not in self.partitions[i]:
                    self.partitions[i].append(m)
                    m.add_parent_link(self, i)

        for parent, i in machine2.parents:
            parent.partitions[i].remove(machine2)
            parent.partitions[i].append(self)
            self.add_parent_link(parent, i)

    def d_printname(self):
        """printname for dot output"""
        #TODO
        pn = self.printname_.split('/')[0]
        return Machine.d_clean(pn)

    @staticmethod
    def d_clean(string):
        s = string
        for c in ('=', '@', '-', ',', "'", '"'):
            s = s.replace(c, '_')
        if s == 'edge':
            s += '_'
        elif s == '$':
            s = '_dollars'
        return s

    def printname(self):
        if '/' in self.printname_:
            return self.printname_.split('/')[0]
        return self.printname_

{'fraction_non_alphanumeric': 0.11897307451471509, 'fraction_numerical': 0.005218117303276978, 'mean_word_length': 2.1484888304862024, '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': '6386613', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1424, 'n_words': 337}