Compare two Rats for equality.
(self, other)
| 185 | return divmod(other, self)[1] |
| 186 | |
| 187 | def __eq__(self, other): |
| 188 | """Compare two Rats for equality.""" |
| 189 | if isint(other): |
| 190 | return self.__den == 1 and self.__num == other |
| 191 | if isRat(other): |
| 192 | return self.__num == other.__num and self.__den == other.__den |
| 193 | if isnum(other): |
| 194 | return float(self) == other |
| 195 | return NotImplemented |
| 196 | |
| 197 | class RatTestCase(unittest.TestCase): |
| 198 | """Unit tests for Rat class and its support utilities.""" |