Skip to content

Commit

Permalink
Fix flake8 E111 and E306
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony-Y committed May 11, 2024
1 parent e94a745 commit 3dde049
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pytorch_warmup/untuned.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class UntunedLinearWarmup(LinearWarmup):

def __init__(self, optimizer, last_step=-1):
_check_optimizer(optimizer)

def warmup_period_fn(beta2):
return int(2.0 / (1.0-beta2))
warmup_period = [warmup_period_fn(x['betas'][1]) for x in optimizer.param_groups]
Expand All @@ -35,6 +36,7 @@ class UntunedExponentialWarmup(ExponentialWarmup):

def __init__(self, optimizer, last_step=-1):
_check_optimizer(optimizer)

def warmup_period_fn(beta2):
return int(1.0 / (1.0-beta2))
warmup_period = [warmup_period_fn(x['betas'][1]) for x in optimizer.param_groups]
Expand Down
4 changes: 2 additions & 2 deletions test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _test_optimizer(self, warmup_class):

def _test_get_warmup_params(self, optimizer, warmup_class):
with self.assertRaises(ValueError, msg='warmup_period size') as cm:
warmup_class(optimizer, warmup_period=[5])
warmup_class(optimizer, warmup_period=[5])
self.assertEqual(str(cm.exception), 'The size of warmup_period (1) does not match the size of param_groups (2).')

with self.assertRaises(TypeError, msg='warmup_period element type') as cm:
Expand All @@ -38,7 +38,7 @@ def _test_get_warmup_params(self, optimizer, warmup_class):
self.assertEqual(str(cm.exception), 'warmup_period must be a positive integer, but is 0.')

with self.assertRaises(TypeError, msg='warmup_period type') as cm:
warmup_class(optimizer, warmup_period=5.0)
warmup_class(optimizer, warmup_period=5.0)
self.assertEqual(str(cm.exception), '5.0 (float) is not a list nor an int.')


Expand Down

0 comments on commit 3dde049

Please sign in to comment.