diff --git a/nvitop/api/collector.py b/nvitop/api/collector.py index 9467487..ea81578 100644 --- a/nvitop/api/collector.py +++ b/nvitop/api/collector.py @@ -855,9 +855,10 @@ class _StatisticsMaintainer: # pylint: disable=missing-class-docstring,missing- self.last_timestamp = timestamp def mean(self) -> float: + if self.integral is None: + return math.nan + if self.has_nan: - if self.integral is None: - return math.nan return self.integral / (self.last_timestamp - self.start_timestamp) timestamp = timer() @@ -865,12 +866,12 @@ class _StatisticsMaintainer: # pylint: disable=missing-class-docstring,missing- return integral / (timestamp - self.start_timestamp) def min(self) -> float: - if self.has_nan or self.min_value is None: + if self.min_value is None: return math.nan return self.min_value def max(self) -> float: - if self.has_nan or self.max_value is None: + if self.max_value is None: return math.nan return self.max_value diff --git a/nvitop/api/process.py b/nvitop/api/process.py index 1f451c7..d164579 100644 --- a/nvitop/api/process.py +++ b/nvitop/api/process.py @@ -452,10 +452,10 @@ class GpuProcess: # pylint: disable=too-many-instance-attributes,too-many-publi _pid: int _host: HostProcess - _ident: tuple _device: Device - _hash: int | None _username: str | None + _ident: tuple + _hash: int | None # pylint: disable-next=too-many-arguments def __new__( diff --git a/nvitop/api/utils.py b/nvitop/api/utils.py index d420ffe..f9890ea 100644 --- a/nvitop/api/utils.py +++ b/nvitop/api/utils.py @@ -506,7 +506,7 @@ SIZE_UNITS: dict[str | None, int] = { 'MB': 1000**2, 'GB': 1000**3, 'TB': 1000**4, - 'PB': 1000**4, + 'PB': 1000**5, } """Units of storage and memory measurements.""" SIZE_PATTERN: re.Pattern = re.compile( @@ -694,9 +694,7 @@ class Snapshot: """Support ``for name in snapshot`` syntax and ``*`` tuple unpack ``[*snapshot]`` syntax.""" def gen() -> Generator[str, None, None]: - for name in self.__dict__: - if name not in ('real', 'timestamp'): - yield name + yield from (name for name in self.__dict__ if name not in ('real', 'timestamp')) return gen()