<commit_before>from ed2d.glmath import matrix


class BaseNode(object):
    def __init__(self, obj):
        self.nodeID = None
        self.isRoot = False
        self.root = None
        self.parent = None
        self.children = [self]

    def attach(self, parent):
        self.root = parent.root
        self.parent = parent
        nodeID = self.root._add_tree_child(self)
        self.nodeID = nodeID
        self.parent.children.append(self)
        return nodeID

    def detach(self):
        self.parent.children.remove(node)
        self.root._del_tree_child(self)
        self.parent = None
        self.root = None
        self.nodeID = None

    def recurse(self, callback):
        for i in self.children[1:]:
            callback(self, i)
            i.recurse(callback)

    def recurse_up(self, callback):
        callback(self)
        if not self.parent.isRoot:
            self.parent.recurse_up(callback)

    def reparent(self, parent):
        self.detach()
        self.attach(parent)


class RootNode(BaseNode):
    def __init__(self, obj):
        self.nodeID = 0
        self.treeChildren = [self]
        self.children = [self]
        self.root = self
        self.isRoot = True
        self.nodeCount = 0<commit_msg>Fix typo in scenegraph.py<commit_after>from ed2d.glmath import matrix


class BaseNode(object):
    def __init__(self, obj):
        self.nodeID = None
        self.isRoot = False
        self.root = None
        self.parent = None
        self.children = [self]

    def attach(self, parent):
        self.root = parent.root
        self.parent = parent
        nodeID = self.root._add_tree_child(self)
        self.nodeID = nodeID
        self.parent.children.append(self)
        return nodeID

    def detach(self):
        self.parent.children.remove(self)
        self.root._del_tree_child(self)
        self.parent = None
        self.root = None
        self.nodeID = None

    def recurse(self, callback):
        for i in self.children[1:]:
            callback(self, i)
            i.recurse(callback)

    def recurse_up(self, callback):
        callback(self)
        if not self.parent.isRoot:
            self.parent.recurse_up(callback)

    def reparent(self, parent):
        self.detach()
        self.attach(parent)


class RootNode(BaseNode):
    def __init__(self, obj):
        self.nodeID = 0
        self.treeChildren = [self]
        self.children = [self]
        self.root = self
        self.isRoot = True
        self.nodeCount = 0
{'fraction_non_alphanumeric': 0.09840637450199204, 'fraction_numerical': 0.0031872509960159364, 'mean_word_length': 1.9299883313885648, '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': '3172795', 'n_tokens_mistral': 777, 'n_tokens_neox': 756, 'n_words': 168}