• Home
  • Raw
  • Download

Lines Matching refs:Rat

25     return isinstance(x, Rat)
27 class Rat(object): class
89 other = Rat(other)
91 return Rat(self.__num*other.__den + other.__num*self.__den,
102 other = Rat(other)
104 return Rat(self.__num*other.__den - other.__num*self.__den,
113 other = Rat(other)
115 return Rat(other.__num*self.__den - self.__num*other.__den,
124 return Rat(self.__num*other.__num, self.__den*other.__den)
126 return Rat(self.__num*other, self.__den)
136 return Rat(self.__num*other.__den, self.__den*other.__num)
138 return Rat(self.__num, self.__den*other)
148 return Rat(other.__num*self.__den, other.__den*self.__num)
150 return Rat(other*self.__den, self.__num)
160 other = Rat(other)
174 other = Rat(other)
183 other = Rat(other)
232 a = Rat(10, 15)
235 a = Rat(10L, 15L)
238 a = Rat(10, -15)
241 a = Rat(-10, 15)
244 a = Rat(-10, -15)
247 a = Rat(7)
251 a = Rat(1, 0)
256 for bad in "0", 0.0, 0j, (), [], {}, None, Rat, unittest:
258 a = Rat(bad)
264 a = Rat(1, bad)
271 self.assertEqual(Rat(2, 3) + Rat(1, 3), 1)
272 self.assertEqual(Rat(2, 3) + 1, Rat(5, 3))
273 self.assertEqual(1 + Rat(2, 3), Rat(5, 3))
274 self.assertEqual(1.0 + Rat(1, 2), 1.5)
275 self.assertEqual(Rat(1, 2) + 1.0, 1.5)
278 self.assertEqual(Rat(7, 2) - Rat(7, 5), Rat(21, 10))
279 self.assertEqual(Rat(7, 5) - 1, Rat(2, 5))
280 self.assertEqual(1 - Rat(3, 5), Rat(2, 5))
281 self.assertEqual(Rat(3, 2) - 1.0, 0.5)
282 self.assertEqual(1.0 - Rat(1, 2), 0.5)
285 self.assertEqual(Rat(2, 3) * Rat(5, 7), Rat(10, 21))
286 self.assertEqual(Rat(10, 3) * 3, 10)
287 self.assertEqual(3 * Rat(10, 3), 10)
288 self.assertEqual(Rat(10, 5) * 0.5, 1.0)
289 self.assertEqual(0.5 * Rat(10, 5), 1.0)
292 self.assertEqual(Rat(10, 3) / Rat(5, 7), Rat(14, 3))
293 self.assertEqual(Rat(10, 3) / 3, Rat(10, 9))
294 self.assertEqual(2 / Rat(5), Rat(2, 5))
295 self.assertEqual(3.0 * Rat(1, 2), 1.5)
296 self.assertEqual(Rat(1, 2) * 3.0, 1.5)
299 self.assertEqual(Rat(10) // Rat(4), 2)
300 self.assertEqual(Rat(10, 3) // Rat(4, 3), 2)
301 self.assertEqual(Rat(10) // 4, 2)
302 self.assertEqual(10 // Rat(4), 2)
305 self.assertEqual(Rat(10), Rat(20, 2))
306 self.assertEqual(Rat(10), 10)
307 self.assertEqual(10, Rat(10))
308 self.assertEqual(Rat(10), 10.0)
309 self.assertEqual(10.0, Rat(10))