1515
1616
1717def is_floatable (x ):
18+ '''Can `x` be made into a `float`?'''
1819 try :
1920 float (x )
2021 return True
@@ -23,6 +24,7 @@ def is_floatable(x):
2324
2425
2526def is_nonfractional (x ):
27+ '''Is `x` a whole number?'''
2628 try :
2729 int (x )
2830 return int (x ) == x
@@ -89,7 +91,7 @@ def __div__(self, other):
8991 raise InfinityRaceError
9092 elif is_floatable (other ):
9193 s = math_tools .sign (other )
92- if s == 0 :
94+ if s == 0 :
9395 raise InfinityRaceError
9496 else :
9597 return Infinity (direction = self .direction * s )
@@ -102,7 +104,7 @@ def __mul__(self, other):
102104 return Infinity (self .direction * other .direction )
103105 elif is_floatable (other ):
104106 s = math_tools .sign (other )
105- if s == 0 :
107+ if s == 0 :
106108 raise InfinityRaceError
107109 else :
108110 return Infinity (direction = self .direction * s )
@@ -121,19 +123,19 @@ def __pow__(self, other):
121123 raise object # todo
122124 elif is_floatable (other ):
123125 s = math_tools .sign (other )
124- if s == 0 :
126+ if s == 0 :
125127 raise InfinityRaceError
126128 else :
127- if self .direction == 1 :
128- if s == 1 :
129+ if self .direction == 1 :
130+ if s == 1 :
129131 return self
130- if s == - 1 :
132+ if s == - 1 :
131133 return 0
132134 else : #self.direction == -1
133135 if is_nonfractional (other ):
134- if s == - 1 :
136+ if s == - 1 :
135137 return 0
136- if s == 1 :
138+ if s == 1 :
137139 if s % 2 == 0 :
138140 return Infinity ()
139141 else :
@@ -194,10 +196,10 @@ def __neq__(self, other):
194196 return not self .__eq__ (other )
195197
196198 def __repr__ (self ):
197- if self .direction == 1 :
198- suffix = ''
199+ if self .direction == 1 :
200+ suffix = ''
199201 else : # self.direction == -1
200- suffix = '-'
202+ suffix = '-'
201203 return suffix + 'infinity'
202204
203205
0 commit comments