Computes and stores the average and current value
| 3 | import logging |
| 4 | |
| 5 | class AverageMeter(object): |
| 6 | """ Computes and stores the average and current value """ |
| 7 | def __init__(self): |
| 8 | self.reset() |
| 9 | |
| 10 | def reset(self): |
| 11 | self.val = 0 |
| 12 | self.avg = 0 |
| 13 | self.sum = 0 |
| 14 | self.count = 0 |
| 15 | |
| 16 | def update(self, val, n=1): |
| 17 | self.val = val |
| 18 | self.sum += val * n |
| 19 | self.count += n |
| 20 | self.avg = self.sum / self.count |
| 21 | |
| 22 | class LogFormatter(): |
| 23 | def __init__(self): |
no outgoing calls
no test coverage detected