예제 #1
0
 def test300_950_ShouldRaiseExceptionOnTooHighTails(self):
     myT = TCurve(10)
     try:
         myT.p(42,3)
         self.fail()
     except ValueError as myException:
         self.assertTrue(myException.args[0].startswith("E03:")) 
예제 #2
0
 def test300_970_ShouldRaiseExceptionOnNonIntegerTails(self):
     myT = TCurve(10)
     try:
         myT.p(42,"1")
         self.fail()
     except ValueError as myException:
         self.assertTrue(myException.args[0].startswith("E03:"))                
예제 #3
0
 def test300_930_ShouldRaiseExceptionOnLowT(self):
     myT = TCurve(10)
     try:
         myT.p(-1)
         self.fail()
     except ValueError as myException:
         self.assertTrue(myException.args[0].startswith("E02:")) 
예제 #4
0
 def __testP(self, n, t, tails, ep):
     tc = TCurve(n)
     self.assertIsNotNone(tc, "Constructor failed on n=" + str(n) + ". Returned None.")
     right = 0
     s = 0.0
     avg = 0.0
     results = []
     for i in range(0, 5):
         i = i
         if tails is None:
             p = tc.p(t)
         else:
             p = tc.p(t, tails)
         results.append(round(p, 4))
         s = s + p
         error = math.fabs(ep - p) / ep
         if error <= self.epsilon:
             right = right + 1
         # self.assertAlmostEqual(p, ep, self.precision, "Error in calculating p(" + str(t) + "," + str(tails) + "). Expected " + str(ep) + " got back " + str(p))
     if right < 4:
         avg = s / 5.0
         avg = round(avg, 3)
         resultsList = ""
         results.sort()
         while len(results) > 0:
             resultsList += str(results.pop(0)) + ","
         self.assertAlmostEqual(
             avg,
             ep,
             self.precision,
             "Error in calculating p("
             + str(t)
             + ","
             + str(tails)
             + "). Failed "
             + str(int(5 - right))
             + " times, so checked the average of the results. Expected "
             + str(ep)
             + ", but the average of the p()'s was "
             + str(avg)
             + " ["
             + resultsList
             + "]",
         )
     else:
         self.assertGreaterEqual(
             right,
             4,
             "Error in calculating p(). Only returned an acceptable answer " + str(int(right)) + " out of 5 times.",
         )
예제 #5
0
 def test300_020_ShouldInvokePWithNoTails(self):
     myT = TCurve(10)
     self.assertIsInstance(myT.p(0.1), float)
예제 #6
0
 def test300_010_ShouldInvokePWithTwoParms(self):
     myT = TCurve(10)
     self.assertIsInstance(myT.p(0.1, 1), float)
예제 #7
0
 def testN49(self):
     tc = TCurve(49)
     self.assertIsNotNone(tc, "Constructor failed on n=49. Returned None.")
     n = tc.n()
     self.assertEqual(tc.n(), 49, "Invalid value of n returned. Expected 49, got back " + str(n))
예제 #8
0
 def testN25(self):
     tc = TCurve(25)
     self.assertIsNotNone(tc, "Constructor failed on n=25. Returned None.")
     n = tc.n()
     self.assertEqual(tc.n(), 25, "Invalid value of n returned. Expected 25, got back " + str(n))
예제 #9
0
 def testN3(self):
     tc = TCurve(3)
     self.assertIsNotNone(tc, "Constructor failed on n=3. Returned None.")
     n = tc.n()
     self.assertEqual(tc.n(), 3, "Invalid value of n returned. Expected 3, got back " + str(n))