Project

General

Profile

« Previous | Next » 

Revision 977

exc.py: Added ExPercentTracker to track errors as % of iterations

View differences:

lib/exc.py
47 47
        print_ex(e, **format)
48 48

  
49 49
class ExPercentTracker(ExTracker):
50
    def set_iter_ct(self, iter_ct): self.iter_ct = iter_ct
50
    def __init__(self):
51
        ExTracker.__init__(self)
52
        self.iter_ct = None
51 53
    
52
    def msg(self): return 'Encountered '+str(self.e_ct)+' error(s)'
54
    def add_iters(self, iter_ct):
55
        if self.iter_ct == None: self.iter_ct = 0
56
        self.iter_ct += iter_ct
57
    
58
    def msg(self):
59
        msg = ExTracker.msg(self)
60
        if self.iter_ct != None: msg += ('/'+str(self.iter_ct)+' iterations = '
61
            +util.to_percent(float(self.e_ct)/self.iter_ct))
62
        return msg

Also available in: Unified diff