From 8d18f42c3287ebf3b60051a175cc0b3e6abc2eba Mon Sep 17 00:00:00 2001 From: YuanLiuuuuuu <3463423099@qq.com> Date: Wed, 1 Jun 2022 10:56:20 +0800 Subject: [PATCH] [Fix]: Fix UT --- .../test_hooks/test_cosine_annealing_hook.py | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 tests/test_runtime/test_hooks/test_cosine_annealing_hook.py diff --git a/tests/test_runtime/test_hooks/test_cosine_annealing_hook.py b/tests/test_runtime/test_hooks/test_cosine_annealing_hook.py deleted file mode 100644 index 3c60f78e..00000000 --- a/tests/test_runtime/test_hooks/test_cosine_annealing_hook.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -from unittest.mock import MagicMock - -from mmselfsup.core.hooks import StepFixCosineAnnealingLrUpdaterHook - - -def test_cosine_annealing_hook(): - lr_config = dict( - min_lr=1e-5, - warmup='linear', - warmup_iters=10, - warmup_ratio=1e-4, - warmup_by_epoch=True, - by_epoch=False) - lr_annealing_hook = StepFixCosineAnnealingLrUpdaterHook(**lr_config) - lr_annealing_hook.regular_lr = [1.0] - lr_annealing_hook.warmup_iters = 10 - - # test get_warmup_lr - lr = lr_annealing_hook.get_warmup_lr(1) - assert isinstance(lr, list) - - # test get_lr - # by_epoch = False - runner = MagicMock() - runner.iter = 10 - runner.max_iters = 1000 - lr = lr_annealing_hook.get_lr(runner, 1.5) - assert isinstance(lr, float) - - # by_epoch = True - lr_annealing_hook.by_epoch = True - runner.epoch = 10 - runner.max_epochs = 10 - runner.data_loader = MagicMock() - runner.data_loader.__len__ = MagicMock(return_value=10) - lr = lr_annealing_hook.get_lr(runner, 1.5) - assert isinstance(lr, float)