<commit_before>import functools
import itertools

def normalize_types(f):
    @functools.wraps(f)
    def normalizer(self, region, o):
        '''
        Convert any object to an object that we can process.
        '''
        if isinstance(o, A):
            o = o.model

        assert type(o) is StridedInterval

        return f(self, region, o)

    return normalizer

vs_id_ctr = itertools.count()

class ValueSet(object):
    def __init__(self, name=None, region=None, bits=None, val=None):
        self._name = name
        if self._name is None:
            self._name = 'VS_%d' % vs_id_ctr.next()

        self._regions = {}

        self._reversed = False

        if region is not None and bits is not None and val is not None:
            self.set_si(region, StridedInterval(bits=bits, stride=0, lower_bound=val, upper_bound=val))

    @property
    def name(self):
        return self._name

    @property
    def regions(self):
        return self._regions

    @property
    def reversed(self):
        return self._reversed

    @property
    def unique(self):
        return len(self.regions) == 1 and self.regions.values()[0].unique

    @normalize_types
    def set_si(self, region, si):
        self._regions[region] = si

    def get_si(self, region):
        if region in self._regions:
            return self._regions[region]
        # TODO: Should we return a None, or an empty SI instead?
        return None<commit_msg>added bits property to ValueSet class.<commit_after>import functools
import itertools

def normalize_types(f):
    @functools.wraps(f)
    def normalizer(self, region, o):
        '''
        Convert any object to an object that we can process.
        '''
        if isinstance(o, A):
            o = o.model

        assert type(o) is StridedInterval

        return f(self, region, o)

    return normalizer

vs_id_ctr = itertools.count()

class ValueSet(object):
    def __init__(self, name=None, region=None, bits=None, val=None):
        self._name = name
        if self._name is None:
            self._name = 'VS_%d' % vs_id_ctr.next()

        self._regions = {}

        self._reversed = False

        if region is not None and bits is not None and val is not None:
            self.set_si(region, StridedInterval(bits=bits, stride=0, lower_bound=val, upper_bound=val))

    @property
    def name(self):
        return self._name

    @property
    def regions(self):
        return self._regions

    @property
    def reversed(self):
        return self._reversed

    @property
    def unique(self):
        return len(self.regions) == 1 and self.regions.values()[0].unique

    @property
    def bits(self):
        return self.size()

    @normalize_types
    def set_si(self, region, si):
        self._regions[region] = si

    def get_si(self, region):
        if region in self._regions:
            return self._regions[region]
        # TODO: Should we return a None, or an empty SI instead?
        return None
{'fraction_non_alphanumeric': 0.09587663426081126, 'fraction_numerical': 0.002011397921555481, 'mean_word_length': 2.293598233995585, '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': '7212598', 'n_tokens_mistral': 922, 'n_tokens_neox': 882, 'n_words': 269}