<commit_before>"""
File that implements the RandVar (Random Variable) class
"""


import copy
import math


class RandVar:
    """
    Represents a Random Variable in a probability distribution. Each variable
    is identified by a string which is it's name. If two RandVar in a script
    have the same name, the library will assume they are the same variable.

    Each variable also has a domain. The domain is a list of values which the
    variable can take. As of this version the elements on the list should only
    be of the string type. In later versions other types will be allowed. Maybe
    even types that are other objects.

    :param name:   String or Int with the name of this variable
    :param domain: List with the domain of this variable. The elements in the
                   domain should be strings or ints.

    Examples:
        >>> coin = RandVar("Coin", ["Head", "Tail"])
        >>> ball = RandVar("Ball", ["Red", "Green", "Blue"])
        >>> generic = RandVar(10, list(range(10)))
    """

    def __init__(self, name, domain):
        if type(name) not in [str, int]:
            raise RandVarNameEx(name)

        if type(domain) != list or len(domain) == 0:
            raise RandVarDomainEx(domain)

        for i in domain:
            if type(i) not in [str, int]:
                raise RandVarDomainEx(domain)

        self.name = name
        self.domain = domain

    def equal(self, var):<commit_msg>Made it possible to create random variables with a number describing the domain<commit_after>"""
File that implements the RandVar (Random Variable) class
"""


import copy
import math


class RandVar:
    """
    Represents a Random Variable in a probability distribution. Each variable
    is identified by a string which is it's name. If two RandVar in a script
    have the same name, the library will assume they are the same variable.

    Each variable also has a domain. The domain is a list of values which the
    variable can take. As of this version the elements on the list should only
    be of the string type. In later versions other types will be allowed. Maybe
    even types that are other objects.

    :param name:   String or Int with the name of this variable
    :param domain: Either a list with the domain of this variable, in which the
                   elements in the domain should be strings or ints, or an int
                   number which will be the size of the domain

    Examples:
        >>> coin = RandVar("Coin", ["Head", "Tail"])
        >>> ball = RandVar("Ball", ["Red", "Green", "Blue"])
        >>> generic = RandVar(10, list(range(10)))
        >>> X = RandVar("X", 4)

    In the example, the X variable will have a domain of 4
    """

    def __init__(self, name, domain):
        # Check the name
        if type(name) not in [str, int]:
            raise RandVarNameEx(name)

        # Check the domain
        if type(domain) == list and len(domain) > 0:
            for i in domain:
                if type(i) not in [str, int]:
                    raise RandVarDomainEx(domain)

        elif type(domain) == int:
            domain = list(range(domain))

        else:
            raise RandVarDomainEx(domain)

        # Store the attributes
        self.name = name
        self.domain = domain

    def equal(self, var):
{'fraction_non_alphanumeric': 0.08037326911499097, 'fraction_numerical': 0.003612281757977122, 'mean_word_length': 2.3667679837892606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '3554184', 'n_tokens_mistral': 891, 'n_tokens_neox': 845, 'n_words': 425}