Package teamwork :: Package test :: Package widgets :: Module testMultiscale
[hide private]
[frames] | no frames]

Source Code for Module teamwork.test.widgets.testMultiscale

 1  from teamwork.math.Keys import * 
 2  from teamwork.math.KeyedMatrix import * 
 3  from teamwork.math.probability import * 
 4   
 5  from teamwork.widgets.multiscale import * 
 6   
 7  import unittest 
 8   
9 -class TestMultiscale(unittest.TestCase):
10
11 - def testBlend(self):
12 color = blend('#000000','#a0e040',0.5) 13 self.assertEqual(color,'#507020')
14
15 - def testWidget(self):
16 # Set up distribution to display 17 self.feature = 'containerDanger' 18 self.key = StateKey({'entity':'Shipper','feature':self.feature}) 19 self.dist = Distribution() 20 row = KeyedVector({self.key:0.0}) 21 self.dist[row] = 0.9 22 row = KeyedVector({self.key:0.1}) 23 self.dist[row] = 0.1 24 # Set up Tk 25 self.root = Tk() 26 Pmw.initialise(self.root) 27 # Run widget 28 marginal = self.dist.getMarginal(self.key) 29 widget = DistributionScale(self.root,tag_text=self.feature, 30 distribution=marginal) 31 widget.pack(fill=X,expand=YES) 32 try: 33 self.root.mainloop() 34 except KeyboardInterrupt: 35 pass
36 ## self.assertAlmostEqual(self.dist[row],0.5,9) 37 38 39 if __name__ == '__main__': 40 unittest.main() 41