<commit_before>import sys
import time
import re
import fnmatch
import ROOT
import inspect
from ..types import *
from ..core import Object, camelCaseMethods
from ..utils import *
from ..registry import register
from ..io import open as ropen
from .filtering import *
from ..plotting.core import Plottable
from .. import path

class TreeModel(object):

    @classmethod
    def get_user_attributes(cls):
        boring = dir(type('dummy', (object,), {}))+['get_user_attributes']
        return [item
                for item in inspect.getmembers(cls)
                if item[0] not in boring]


class TreeObject(object):

    def __init__(self, tree, name, prefix):

        self.tree = tree
        self.name = name
        self.prefix = prefix

    def __getitem__(self, thing):

        return getattr(self, thing)
         
    def __getattr__(self, attr):
        
        if attr.startswith(self.prefix):
            return getattr(self.tree, attr)
        return getattr(self.tree, self.prefix + attr)


class TreeCollectionObject(TreeObject):

    def __init__(self, tree, name, prefix, index):

        self.index = index
        super(TreeCollectionObject, self).__init__(tree, name, prefix)
         
    def __getattr__(self, attr):
        
        if attr.startswith(self.prefix):
            return getattr(self.tree, attr)[self.index]
        return getattr(self.tree, self.prefix + attr)[self.index]


__MIXINS__ = {}

def mix_treeobject(mixin):

    class TreeObject_mixin(TreeObject, mixin):
        
        def __init__(self, *args, **kwargs):

            TreeObject.__init__(self, *args, **kwargs)
            mixin.__init__(self)

    return TreeObject_mixin

def mix_treecollectionobject(mixin):

    class TreeCollectionObject_mixin(TreeCollectionObject, mixin):
        
        def __init__(self, *args, **kwargs):

            TreeCollectionObject.__init__(self, *args, **kwargs)
            mixin.__init__(self)

    return TreeCollectionObject_mixin
<commit_msg>add equality operator for TreeObject and TreeCollectionObject<commit_after>import sys
import time
import re
import fnmatch
import ROOT
import inspect
from ..types import *
from ..core import Object, camelCaseMethods
from ..utils import *
from ..registry import register
from ..io import open as ropen
from .filtering import *
from ..plotting.core import Plottable
from .. import path

class TreeModel(object):

    @classmethod
    def get_user_attributes(cls):
        boring = dir(type('dummy', (object,), {}))+['get_user_attributes']
        return [item
                for item in inspect.getmembers(cls)
                if item[0] not in boring]


class TreeObject(object):

    def __init__(self, tree, name, prefix):

        self.tree = tree
        self.name = name
        self.prefix = prefix

    def __eq__(self, other):

        return self.name == other.name and \
               self.prefix == other.prefix
    
    def __getitem__(self, thing):

        return getattr(self, thing)
         
    def __getattr__(self, attr):
        
        if attr.startswith(self.prefix):
            return getattr(self.tree, attr)
        return getattr(self.tree, self.prefix + attr)


class TreeCollectionObject(TreeObject):

    def __init__(self, tree, name, prefix, index):

        self.index = index
        super(TreeCollectionObject, self).__init__(tree, name, prefix)
    
    def __eq__(self, other):

        return self.index == other.index and \
               TreeObject.__eq__(self, other)

    def __getattr__(self, attr):
        
        if attr.startswith(self.prefix):
            return getattr(self.tree, attr)[self.index]
        return getattr(self.tree, self.prefix + attr)[self.index]


__MIXINS__ = {}

def mix_treeobject(mixin):

    class TreeObject_mixin(TreeObject, mixin):
        
        def __init__(self, *args, **kwargs):

            TreeObject.__init__(self, *args, **kwargs)
            mixin.__init__(self)

    return TreeObject_mixin

def mix_treecollectionobject(mixin):

    class TreeCollectionObject_mixin(TreeCollectionObject, mixin):
        
        def __init__(self, *args, **kwargs):

            TreeCollectionObject.__init__(self, *args, **kwargs)
            mixin.__init__(self)

    return TreeCollectionObject_mixin

{'fraction_non_alphanumeric': 0.0982686008423023, 'fraction_numerical': 0.0004679457182966776, 'mean_word_length': 2.635204081632653, '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': '5152263', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1199, 'n_words': 326}