Пример #1
0
    def __eq__(self, other, deep=False):
        if self.index != other.index:
            return False
        if self.time_index != other.time_index:
            return False
        if self.secondary_time_index != other.secondary_time_index:
            return False
        if len(self.variables) != len(other.variables):
            return False
        for v in self.variables:
            if v not in other.variables:
                return False
        if deep:
            if self.last_time_index is None and other.last_time_index is not None:
                return False
            elif self.last_time_index is not None and other.last_time_index is None:
                return False
            elif self.last_time_index is not None and other.last_time_index is not None:
                if not self.last_time_index.equals(other.last_time_index):
                    return False

            if not _dataframes_equal(self.df, other.df):
                return False

        return True
Пример #2
0
 def __eq__(self, other, deep=False):
     if self.index != other.index:
         return False
     if self.time_index != other.time_index:
         return False
     if self.secondary_time_index != other.secondary_time_index:
         return False
     if len(self.variables) != len(other.variables):
         return False
     if set(self.variables) != set(other.variables):
         return False
     if deep:
         if self.last_time_index is None and other.last_time_index is not None:
             return False
         elif self.last_time_index is not None and other.last_time_index is None:
             return False
         elif self.last_time_index is not None and other.last_time_index is not None:
             if not self.last_time_index.equals(other.last_time_index):
                 return False
         if not _dataframes_equal(self.df, other.df):
             return False
         variables = {variable: (variable, ) for variable in self.variables}
         for variable in other.variables:
             variables[variable] += (variable, )
         for self_var, other_var in variables.values():
             if not self_var.__eq__(other_var, deep=True):
                 return False
     return True
Пример #3
0
    def __eq__(self, other, deep=False):
        if self.index != other.index:
            return False
        if self.time_index != other.time_index:
            return False
        if self.secondary_time_index != other.secondary_time_index:
            return False
        if len(self.variables) != len(other.variables):
            return False
        for v in self.variables:
            if v not in other.variables:
                return False
        if deep:
            if self.last_time_index is None and other.last_time_index is not None:
                return False
            elif self.last_time_index is not None and other.last_time_index is None:
                return False
            elif self.last_time_index is not None and other.last_time_index is not None:
                if not self.last_time_index.equals(other.last_time_index):
                    return False

            if not _dataframes_equal(self.df, other.df):
                return False

        return True
Пример #4
0
    def __eq__(self, other, deep=False):
        if self.index != other.index:
            return False
        if self.time_index != other.time_index:
            return False
        if self.secondary_time_index != other.secondary_time_index:
            return False
        if len(self.variables) != len(other.variables):
            return False
        for v in self.variables:
            if v not in other.variables:
                return False
        if deep:
            if self.indexed_by is None and other.indexed_by is not None:
                return False
            elif self.indexed_by is not None and other.indexed_by is None:
                return False
            else:
                for v, index_map in self.indexed_by.items():
                    if v not in other.indexed_by:
                        return False
                    for i, related in index_map.items():
                        if i not in other.indexed_by[v]:
                            return False
                        # indexed_by maps instances of two entities together by lists
                        # We want to check that all the elements of the lists of instances
                        # for each relationship are the same in both entities being
                        # checked for equality, but don't care about the order.
                        if not set(related) == set(other.indexed_by[v][i]):
                            return False
            if self.last_time_index is None and other.last_time_index is not None:
                return False
            elif self.last_time_index is not None and other.last_time_index is None:
                return False
            elif self.last_time_index is not None and other.last_time_index is not None:
                if not self.last_time_index.equals(other.last_time_index):
                    return False

            if not _dataframes_equal(self.df, other.df):
                return False

        return True