<commit_before>"""
TODO
"""


from ProbPy.prob.rand_var import RandVar
from ProbPy.prob.factor import Factor
import copy


class Dist:
    def __init__(self, factor=None, left_vars=None, right_vars=None,
                 values=None):
        # If the argument used is a factor
        if factor is not None:
            # Check if there were any variables in left_vars argument. If there
            # weren't, assume every variable in factor is a left variable
            if left_vars is None:
                self.left_vars = factor.rand_vars[:]
                self.right_vars = []

            # If there were variables in left
            else:
                if type(left_vars) == RandVar:
                    self.left_vars = [left_vars]
                elif type(left_vars) == list:
                    self.left_vars = left_vars[:]
                else:
                    raise Exception

                # Check right variables store them if needed
                if right_vars is not None:
                    if type(right_vars) == RandVar:
                        self.right_vars = [right_vars]
                    elif type(right_vars) == list:
                        self.right_vars = right_vars[:]
                    else:
                        raise Exception
                else:
                    self.right_vars = []

            # Copy the factor
            self.factor = copy.deepcopy(factor)

            # Check if the variables are not repeating
            vars_list = self.left_vars + self.right_vars
            for i in range(len(vars_list)):
                for j in range(i+1, len(vars_list)):
                    if vars_list[i].name == vars_list[j].name:
                        raise Exception

        # If there is no factor
        elif left_vars is not None and values is not None:
            # Make left vars list
            rand_vars = []
            if type(left_vars) == RandVar:
                self.left_vars = [left_vars]
            elif type(left_vars) == list:
                self.left_vars = left_vars[:]
            else:
                raise Exception

            # Make right vars list
            if right_vars is not None:
                if type(right_vars) == RandVar:
                    self.right_vars = [right_vars]
                elif type(right_vars) == list:
                    self.right_vars = right_vars[:]
                else:
                    raise Exception
            else:
                self.right_vars = []

            # Make rand_vars list for factor
            rand_vars = self.left_vars + self.right_vars

            # Build values array if it is not a list
            if type(values) is not list:
                values = self.makeValuesFromFunction(rand_vars, values)

            # Make factor
            self.factor = Factor(rand_vars, values)<commit_msg>Dist class build by inheritance and not by composition<commit_after>"""
TODO
"""


from ProbPy.prob.rand_var import RandVar
from ProbPy.prob.factor import Factor
import copy


class Dist(Factor):
    def __init__(self, factor=None, left_vars=None, right_vars=None,
                 values=None):

        # If the argument used is a factor
        if factor is not None:
            # Check if there were any variables in left_vars argument. If there
            # weren't, assume every variable in factor is a left variable
            if left_vars is None:
                self.left_vars = factor.rand_vars[:]
                self.right_vars = []

            # If there were variables in left
            else:
                if type(left_vars) == RandVar:
                    self.left_vars = [left_vars]
                elif type(left_vars) == list:
                    self.left_vars = left_vars[:]
                else:
                    raise Exception

                # Check right variables store them if needed
                if right_vars is not None:
                    if type(right_vars) == RandVar:
                        self.right_vars = [right_vars]
                    elif type(right_vars) == list:
                        self.right_vars = right_vars[:]
                    else:
                        raise Exception
                else:
                    self.right_vars = []

            # Copy the factor
            # self.factor = copy.deepcopy(factor)
            Factor.__init__(self, factor.rand_vars, factor.values)

            # Check if the variables are not repeating
            vars_list = self.left_vars + self.right_vars
            for i in range(len(vars_list)):
                for j in range(i+1, len(vars_list)):
                    if vars_list[i].name == vars_list[j].name:
                        raise Exception

        # If there is no factor
        elif left_vars is not None and values is not None:
            # Make left vars list
            rand_vars = []
            if type(left_vars) == RandVar:
                self.left_vars = [left_vars]
            elif type(left_vars) == list:
                self.left_vars = left_vars[:]
            else:
                raise Exception

            # Make right vars list
            if right_vars is not None:
                if type(right_vars) == RandVar:
                    self.right_vars = [right_vars]
                elif type(right_vars) == list:
                    self.right_vars = right_vars[:]
                else:
                    raise Exception
            else:
                self.right_vars = []

            # Make rand_vars list for factor
            rand_vars = self.left_vars + self.right_vars

            # Build values array if it is not a list
            if type(values) is not list:
                values = self.makeValuesFromFunction(rand_vars, values)

            # Make factor
            # self.factor = Factor(rand_vars, values)
            Factor.__init__(self, rand_vars, values)
{'fraction_non_alphanumeric': 0.06939742721733243, 'fraction_numerical': 0.00033852403520649965, 'mean_word_length': 1.3411251980982568, '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': '3904862', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1429, 'n_words': 459}