Skip to content

Commit

Permalink
remove typing.Self
Browse files Browse the repository at this point in the history
  • Loading branch information
ain-soph committed Nov 5, 2024
1 parent bd76af7 commit b625783
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ChatTTS/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections import defaultdict, deque
from tqdm import tqdm as tqdm_class

from typing import Generator, Iterable, Self, TypeVar
from typing import Generator, Iterable, TypeVar

import torch
import torch.distributed as dist
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(
self.total: float = 0.0
self.fmt = fmt

def update(self, value: float, n: int = 1) -> Self:
def update(self, value: float, n: int = 1) -> 'SmoothedValue':
r"""Update :attr:`n` pieces of data with same :attr:`value`.
.. code-block:: python
Expand All @@ -78,7 +78,7 @@ def update(self, value: float, n: int = 1) -> Self:
self.count += n
return self

def update_list(self, value_list: list[float]) -> Self:
def update_list(self, value_list: list[float]) -> 'SmoothedValue':
r"""Update :attr:`value_list`.
.. code-block:: python
Expand All @@ -100,7 +100,7 @@ def update_list(self, value_list: list[float]) -> Self:
self.count += len(value_list)
return self

def reset(self) -> Self:
def reset(self) -> 'SmoothedValue':
r"""Reset ``deque``, ``count`` and ``total`` to be empty.
Returns:
Expand Down Expand Up @@ -227,7 +227,7 @@ def __init__(
self.data_time = SmoothedValue()
self.memory = SmoothedValue(fmt="{max:.0f}")

def create_meters(self, **kwargs: str) -> Self:
def create_meters(self, **kwargs: str) -> 'SmoothedValue':
r"""Create meters with specific ``fmt`` in :attr:`self.meters`.
``self.meters[meter_name] = SmoothedValue(fmt=fmt)``
Expand All @@ -243,7 +243,7 @@ def create_meters(self, **kwargs: str) -> Self:
fmt="{global_avg:.3f}" if v is None else v)
return self

def update(self, n: int = 1, **kwargs: float) -> Self:
def update(self, n: int = 1, **kwargs: float) -> 'SmoothedValue':
r"""Update values to :attr:`self.meters` by calling :meth:`SmoothedValue.update()`.
``self.meters[meter_name].update(float(value), n=n)``
Expand All @@ -261,7 +261,7 @@ def update(self, n: int = 1, **kwargs: float) -> Self:
self.meters[k].update(float(v), n=n)
return self

def update_list(self, **kwargs: list) -> Self:
def update_list(self, **kwargs: list) -> 'SmoothedValue':
r"""Update values to :attr:`self.meters` by calling :meth:`SmoothedValue.update_list()`.
``self.meters[meter_name].update_list(value_list)``
Expand All @@ -276,7 +276,7 @@ def update_list(self, **kwargs: list) -> Self:
self.meters[k].update_list(v)
return self

def reset(self) -> Self:
def reset(self) -> 'SmoothedValue':
r"""Reset meter in :attr:`self.meters` by calling :meth:`SmoothedValue.reset()`.
Returns:
Expand Down

0 comments on commit b625783

Please sign in to comment.