Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:30

0001 from __future__ import absolute_import
0002 import unittest
0003 
0004 from .average import Average
0005 
0006 class AverageTestCase(unittest.TestCase):
0007 
0008     def test_ave_unw(self):
0009         c = Average('TestAve')
0010         c.add( 1, 1 )
0011         c.add( 2, 1 )
0012         ave, unc = c.average()
0013         self.assertEqual(ave, 1.5)
0014 
0015     def test_ave_wei(self):
0016         c = Average('TestAve')
0017         c.add( 0, 1 )
0018         c.add( 1, 3 )
0019         ave, unc = c.average()
0020         self.assertEqual(ave, 0.75)
0021 
0022     def test_ave_add(self):
0023         c1 = Average('c1')
0024         c1.add(0,1)
0025         c2 = Average('c2')
0026         c2.add(1,3)
0027         c3 = c1 + c2
0028         ave, unc = c3.average()
0029         self.assertEqual(ave, 0.75)
0030 
0031 if __name__ == '__main__':
0032     unittest.main()