Skip to content

Commit

Permalink
Apply black to fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Jan 30, 2025
1 parent a3f85ea commit 659c5aa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion optunahub/_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def cache_home() -> str:
)
else: # UNIX-like
return os.path.join(
os.getenv("XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache")),
os.getenv(
"XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache")
),
"optunahub",
)

Expand Down
4 changes: 3 additions & 1 deletion optunahub/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def load_module(
hostname = urlparse(base_url).hostname
if hostname is None:
raise ValueError(f"Invalid base URL: {base_url}")
cache_dir_prefix = os.path.join(_conf.cache_home(), hostname, repo_owner, repo_name, ref)
cache_dir_prefix = os.path.join(
_conf.cache_home(), hostname, repo_owner, repo_name, ref
)
package_cache_dir = os.path.join(cache_dir_prefix, dir_path)
use_cache = not force_reload and os.path.exists(package_cache_dir)

Expand Down
12 changes: 9 additions & 3 deletions optunahub/samplers/_simple_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class SimpleBaseSampler(BaseSampler, abc.ABC):
"""A simple base class to implement user-defined samplers."""

def __init__(
self, search_space: dict[str, BaseDistribution] | None = None, seed: int | None = None
self,
search_space: dict[str, BaseDistribution] | None = None,
seed: int | None = None,
) -> None:
self.search_space = search_space
self._seed = seed
Expand Down Expand Up @@ -53,7 +55,9 @@ def sample_independent(
) -> Any:
# This method is optional.
# By default, parameter values are sampled by ``optuna.samplers.RandomSampler``.
return self._default_sample_independent(study, trial, param_name, param_distribution)
return self._default_sample_independent(
study, trial, param_name, param_distribution
)

def reseed_rng(self) -> None:
self._default_reseed_rng()
Expand All @@ -66,7 +70,9 @@ def _default_infer_relative_search_space(
self, study: Study, trial: FrozenTrial
) -> dict[str, BaseDistribution]:
search_space: dict[str, BaseDistribution] = {}
for name, distribution in self._intersection_search_space.calculate(study).items():
for name, distribution in self._intersection_search_space.calculate(
study
).items():
if distribution.single():
# Single value objects are not sampled with the `sample_relative` method,
# but with the `sample_independent` method.
Expand Down
4 changes: 3 additions & 1 deletion tests/package_for_test_hub/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@


class TestSampler(optunahub.samplers.SimpleBaseSampler):
def __init__(self, search_space: Optional[Dict[str, BaseDistribution]] = None) -> None:
def __init__(
self, search_space: Optional[Dict[str, BaseDistribution]] = None
) -> None:
super().__init__(search_space)
self._rng = np.random.RandomState()

Expand Down

0 comments on commit 659c5aa

Please sign in to comment.