Skip to content

Commit

Permalink
mypy again
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 authored and leej3 committed May 21, 2024
1 parent 5db5faf commit b9015f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ignite/handlers/param_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections import OrderedDict
from copy import copy
from pathlib import Path
from typing import Any, cast, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union

import torch
from torch.optim.lr_scheduler import CosineAnnealingWarmRestarts, ReduceLROnPlateau
Expand Down Expand Up @@ -992,7 +992,7 @@ def get_param(self) -> Union[float, List[float]]:
"""Method to get current optimizer's parameter value"""
# Emulate context manager for pytorch>=1.4
self.lr_scheduler._get_lr_called_within_step = True # type: ignore[union-attr]
lr_list = cast(List[float], self.lr_scheduler.get_lr()) # type: ignore[redundant_cast]
lr_list = self.lr_scheduler.get_lr()
self.lr_scheduler._get_lr_called_within_step = False # type: ignore[union-attr]
if len(lr_list) == 1:
return lr_list[0]
Expand Down Expand Up @@ -1670,7 +1670,7 @@ def __init__(
_scheduler_kwargs["verbose"] = False

self.scheduler = ReduceLROnPlateau(optimizer, **_scheduler_kwargs)
self.scheduler._reduce_lr = self._reduce_lr # type: ignore[assignment]
self.scheduler._reduce_lr = self._reduce_lr # type: ignore[method-assign]

self._state_attrs += ["metric_name", "scheduler"]

Expand Down

0 comments on commit b9015f6

Please sign in to comment.