Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaosu-zhu committed Nov 29, 2022
1 parent 85cd2e9 commit 4a32182
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vlutils/metrics/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def to(self, device: Any) -> "Handler":

@property
def ShowInSummary(self) -> bool:
"""True only if results can be represented in summary string.
"""
return True

@property
Expand All @@ -37,6 +39,9 @@ def __call__(self, *args: Any, **kwds: Any):
def __str__(self) -> str:
return self._format % (self.accumulated / self.length)

def __repr__(self) -> str:
return self.__class__.__name__ + ": " + str(self)

def reset(self):
self.accumulated = 0.0
self.length = 0
Expand All @@ -58,10 +63,7 @@ def reset(self):
handler.reset()

def summary(self, reset: bool = False):
result = ", ".join("%s: %s" %
(handler.__class__.__name__, handler)
for handler
in self._handlers if handler.ShowInSummary)
result = ", ".join(repr(handler.__class__.__name__, handler) for handler in self._handlers if handler.ShowInSummary)
if reset:
self.reset()
return result
Expand Down

0 comments on commit 4a32182

Please sign in to comment.