Changeset - 57809e0ef359
[Not reviewed]
default
0 1 0
drewp - 22 years ago 2003-06-14 14:47:34

more precision on output; fewer default sample count
1 file changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light8/updatefreq.py
Show inline comments
 
@@ -9,7 +9,7 @@ class Updatefreq:
 
    the samples param to __init__ specifies how many past updates will
 
    be stored.  """
 
    
 
    def __init__(self,samples=40):
 
    def __init__(self,samples=20):
 
        self.times=[0]
 
        self.samples=samples
 

	
 
@@ -24,7 +24,10 @@ class Updatefreq:
 
        """a cheap algorithm, for now, which looks at the first and
 
        last times only"""
 

	
 
        hz=len(self.times)/(self.times[-1]-self.times[0])
 
        try:
 
            hz=len(self.times)/(self.times[-1]-self.times[0])
 
        except ZeroDivisionError:
 
            return 0
 
        return hz
 
    def __str__(self):
 
        return "%.1fHz"%float(self)
 
        return "%.2fHz"%float(self)
0 comments (0 inline, 0 general)