Skip to content

Commit

Permalink
Merge pull request optuna#5442 from nabenabe0928/code-fix/introduce-f…
Browse files Browse the repository at this point in the history
…uture-annotations-to-base-sampler

Add `__future__.annotations` to base sampler
  • Loading branch information
not522 authored May 21, 2024
2 parents 3aac18f + c2fc255 commit a9b1c23
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions optuna/samplers/_base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from __future__ import annotations

import abc
from collections.abc import Callable
from collections.abc import Sequence
from typing import Any
from typing import Callable
from typing import Dict
from typing import Optional
from typing import Sequence
from typing import TYPE_CHECKING
import warnings

Expand Down Expand Up @@ -59,7 +57,7 @@ def __str__(self) -> str:
@abc.abstractmethod
def infer_relative_search_space(
self, study: Study, trial: FrozenTrial
) -> Dict[str, BaseDistribution]:
) -> dict[str, BaseDistribution]:
"""Infer the search space that will be used by relative sampling in the target trial.
This method is called right before :func:`~optuna.samplers.BaseSampler.sample_relative`
Expand All @@ -86,8 +84,8 @@ def infer_relative_search_space(

@abc.abstractmethod
def sample_relative(
self, study: Study, trial: FrozenTrial, search_space: Dict[str, BaseDistribution]
) -> Dict[str, Any]:
self, study: Study, trial: FrozenTrial, search_space: dict[str, BaseDistribution]
) -> dict[str, Any]:
"""Sample parameters in a given search space.
This method is called once at the beginning of each trial, i.e., right before the
Expand Down Expand Up @@ -181,7 +179,7 @@ def after_trial(
study: Study,
trial: FrozenTrial,
state: TrialState,
values: Optional[Sequence[float]],
values: Sequence[float] | None,
) -> None:
"""Trial post-processing.
Expand Down

0 comments on commit a9b1c23

Please sign in to comment.