Package teamwork :: Package utils :: Module FriendlyFloat
[hide private]
[frames] | no frames]

Source Code for Module teamwork.utils.FriendlyFloat

 1  """Conversion of float values to hide the scary scary numbers""" 
 2   
 3  # User friendly strings for thresholds 
 4  levelStrings = {-.6: 'strong negative', 
 5                  -.3: 'negative', 
 6                  0.0: 'weak negative', 
 7                  0.3: 'weak positive', 
 8                  0.6: 'positive', 
 9                  1.0: 'strong positive' 
10                  } 
11  _levels = levelStrings.keys() 
12  _levels.sort() 
13   
14 -def getLevels():
15 return _levels
16
17 -def simpleFloat(value):
18 for level in _levels: 19 if value <= level: 20 return levelStrings[level] 21 else: 22 return 'very high'
23 ## raise ValueError,'Value exceeds maximum level: %5.3f' % (value) 24