@@ -347,34 +347,26 @@ def make_proxy(self):
347347 return var
348348
349349 def __eq__ (self , other ):
350- # pylint: disable=protected-access,import-outside-toplevel
351-
352- def to_match (var ):
353- if var ._compute_value is None :
354- return var
355- elif isinstance (var ._compute_value , Identity ):
356- return var ._compute_value .variable
357- return None
350+ if type (self ) is not type (other ):
351+ return False
358352
359- from Orange .preprocess .transformation import Identity
360- return type (self ) is type (other ) and (
361- self .name == other .name
362- and self ._compute_value == other ._compute_value
363- or
364- (self .compute_value or other .compute_value )
365- and to_match (self ) == to_match (other ) != None )
353+ var1 = self ._get_identical_source (self )
354+ var2 = self ._get_identical_source (other )
355+ # pylint: disable=protected-access
356+ return var1 .name == var2 .name \
357+ and var1 ._compute_value == var2 ._compute_value
366358
367359 def __hash__ (self ):
368- # Two variables that are not equal can have the same hash.
369- # This happens if one has compute_value == Identity and the other
370- # doesn't have compute_value, or they have a different Identity.
371- # Having the same hash while not being equal is of course allowed.
372- # pylint: disable=import-outside-toplevel
360+ var = self ._get_identical_source (self )
361+ return hash ((var .name , type (self ), var ._compute_value ))
362+
363+ @staticmethod
364+ def _get_identical_source (var ):
365+ # pylint: disable=protected-access,import-outside-toplevel
373366 from Orange .preprocess .transformation import Identity
374- compute_value = self ._compute_value
375- if isinstance (self ._compute_value , Identity ):
376- compute_value = None
377- return hash ((self .name , type (self ), compute_value ))
367+ while isinstance (var ._compute_value , Identity ):
368+ var = var ._compute_value .variable
369+ return var
378370
379371 @classmethod
380372 def make (cls , name , * args , ** kwargs ):
0 commit comments