<commit_before>class UnionFind:
    def __init__(self, it=None):
        self.uf = {} if it is None else {i : i for i in it}

        self.count = len(self.uf)

    def __iter__(self):
        return iter(self.uf.keys())

    def __getitem__(self, key):
        return self.uf[key]

    def __setitem__(self, key, val):
        if key is not val:
            raise RuntimeError("key and val must be the same object")

        self.uf[key] = key

class QuickFind(UnionFind):
    def find(self, key):
        return self.uf[key]

    def union(self, key1, key2):
        u1 = self.find(key1)
        u2 = self.find(key2)

        if u1 == u2: return

        for i in range(len(self.uf)):
            if self.uf[i] == u1:
                self.uf[i] = u2

        self.count -= 1

class QuickUnion(UnionFind):
    def find(self, key):
        while self.uf[key] != key:
            key = self.uf[key]
<commit_msg>Fix QuickFind: stop relying on keys being integers<commit_after>class UnionFind:
    def __init__(self, it=None):
        self.uf = {} if it is None else {i : i for i in it}

        self.count = len(self.uf)

    def __iter__(self):
        return iter(self.uf.keys())

    def __getitem__(self, key):
        return self.uf[key]

    def __setitem__(self, key, val):
        if key is not val:
            raise RuntimeError("key and val must be the same object")

        self.uf[key] = key

class QuickFind(UnionFind):
    def find(self, key):
        return self.uf[key]

    def union(self, key1, key2):
        u1 = self.find(key1)
        u2 = self.find(key2)

        if u1 == u2: return

        for k in self.uf:
            if self.uf[k] == u1:
                self.uf[k] = u2

        self.count -= 1

class QuickUnion(UnionFind):
    def find(self, key):
        while self.uf[key] != key:
            key = self.uf[key]

{'fraction_non_alphanumeric': 0.12086720867208672, 'fraction_numerical': 0.011924119241192412, 'mean_word_length': 1.911671924290221, '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': '3774989', 'n_tokens_mistral': 632, 'n_tokens_neox': 607, 'n_words': 183}