Back to index

python-biopython  1.60
test_Chi2.py
Go to the documentation of this file.
00001 # Copyright (C) 2011 by Brandon Invergo (b.invergo@gmail.com)
00002 # This code is part of the Biopython distribution and governed by its
00003 # license. Please see the LICENSE file that should have been included
00004 # as part of this package.
00005 
00006 import unittest
00007 import os
00008 import os.path
00009 import sys
00010 from Bio.Phylo.PAML import chi2
00011 
00012 class ModTest(unittest.TestCase):
00013 
00014     def testCdfChi2(self):
00015         self.assertRaises(ValueError, chi2.cdf_chi2, df = 0, stat = 3.84)
00016         self.assertRaises(ValueError, chi2.cdf_chi2, df = 1, stat = -3.84)
00017         self.assertRaises(TypeError, chi2.cdf_chi2, df = "d", stat ="stat")
00018         self.assertAlmostEqual(chi2.cdf_chi2(2, 3.84), 0.1466070, places=5)
00019 
00020     def testLnGamma(self):
00021         self.assertRaises(ValueError, chi2._ln_gamma_function, -1)
00022         self.assertAlmostEqual(chi2._ln_gamma_function(10), 12.80183,
00023                                places=5)
00024 
00025     def testIncompleteGamma(self):
00026         self.assertRaises(ValueError, chi2._incomplete_gamma, x = 0.5, 
00027                           alpha = -1)
00028         self.assertAlmostEqual(chi2._incomplete_gamma(0.5, 0.5), 0.6826895,
00029                                places=5)
00030 
00031 if __name__ == "__main__":
00032     runner = unittest.TextTestRunner(verbosity = 2)
00033     unittest.main(testRunner=runner)