Skip to content

Commit

Permalink
Change WarningCache to subclass set (#7995)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca authored Jun 16, 2021
1 parent 4ffba60 commit 2134216
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions pytorch_lightning/utilities/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
from pytorch_lightning.utilities.distributed import rank_zero_warn


class WarningCache:

def __init__(self):
self.warnings = set()
class WarningCache(set):

def warn(self, m, *args, **kwargs):
if m not in self.warnings:
self.warnings.add(m)
if m not in self:
self.add(m)
rank_zero_warn(m, *args, **kwargs)

def clear(self):
self.warnings.clear()

0 comments on commit 2134216

Please sign in to comment.