@@ -57,9 +57,9 @@ def __iter__(self) -> Iterable:
5757 def __gt__ (self , other : object ) -> bool :
5858 match other :
5959 case int ():
60- return self .upper > other
60+ return self .lower > other
6161 case UnInt ():
62- return self .upper > other .lower
62+ return self .lower > other .upper
6363 case _:
6464 return NotImplemented
6565
@@ -90,22 +90,22 @@ def _replace_with(self, other_lower, other_upper, op):
9090 self , lower = op (self .lower , other_lower ), upper = op (self .upper , other_upper )
9191 )
9292
93- def __add__ (self , other : object ) -> bool :
93+ def __add__ (self , other : object ) -> "UnInt" :
9494 match other :
9595 case int ():
9696 # increase both values by the added amount
9797 add_values = (other , other )
9898 case UnInt ():
99- # subtract the upper and lower values by the other lower and upper
100- # to include the largest range of possible values
99+ # add other lower value to current lower and other upper
100+ # to current upper to include the largest range of possible values
101101 # (when calculating with uncertain values, the uncertainty increases)
102102 add_values = (other .lower , other .upper )
103103 case _:
104104 return NotImplemented
105105
106106 return self ._replace_with (* add_values , operator .add )
107107
108- def __sub__ (self , other ):
108+ def __sub__ (self , other ) -> "UnInt" :
109109 match other :
110110 case int ():
111111 # decrease both values by the subtracted amount
@@ -147,14 +147,12 @@ def __repr__(self):
147147 # specifies full UnInt initialization with upper and lower keywords
148148 return f"{ self .__class__ .__name__ } (days=[{ self .days .lower } ,{ self .days .upper } ])"
149149
150- # TODO: what does equality for an uncertain range mean?
151- # is an uncertain range ever equal to another uncertain range?
152-
153150 def __eq__ (self , other : object ) -> bool :
154151 # is an uncertain duration ever *equal* another, even if the values are the same?
155- if other is self :
156- return True
157- return False
152+ # for now, make the assumption that we only want identity equality
153+ # and not value equality; perhaps in future we can revisit
154+ # or add functions to check value equality / equivalence / similarity
155+ return other is self
158156
159157 def __lt__ (self , other : object ) -> bool :
160158 match other :
0 commit comments