Exemple #1
0
class ValueTestRational(unittest.TestCase):
    "rational-specific unit tests"

    R.initialize(Options(dict()))
    f13 = R(1)/R(3)
    f15 = R(1)/R(5)
    f17 = R(1)/R(7)

    def testRat1(self):
        "no loss of precision"
        self.assertEqual(self.f13 * R(3), R(1))
        
    def testMulDiv(self):
        "rational muldiv is the same as multiply followed by divide"
        self.assertEqual(R.muldiv(self.f13, self.f15, self.f17), self.f13*self.f15/self.f17)
Exemple #2
0
 def setUp(self):
     "initialize guarded and rational"
     R.initialize(Options(dict(arithmetic='rational', display=self.p)))
     G.initialize(Options(dict(arithmetic='guarded', precision=self.p, guard=self.g)))