Skip to content

Commit

Permalink
style: ruff formatting pass
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Jan 8, 2025
1 parent 2fc5c36 commit b764ccf
Show file tree
Hide file tree
Showing 47 changed files with 354 additions and 327 deletions.
20 changes: 10 additions & 10 deletions neps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@

__all__ = [
"Architecture",
"Integer",
"Float",
"Categorical",
"Constant",
"Function",
"ArchitectureParameter",
"Categorical",
"CategoricalParameter",
"Constant",
"ConstantParameter",
"Float",
"FloatParameter",
"IntegerParameter",
"Function",
"FunctionParameter",
"run",
"plot",
"get_summary_dict",
"status",
"GraphGrammar",
"GraphGrammarCell",
"GraphGrammarRepetitive",
"Integer",
"IntegerParameter",
"get_summary_dict",
"plot",
"run",
"status",
"tblogger",
]
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

__all__ = [
"AcquisitionMapping",
"BaseAcquisition",
"ComprehensiveExpectedImprovement",
"UpperConfidenceBound",
"BaseAcquisition",
]
14 changes: 7 additions & 7 deletions neps/optimizers/multi_fidelity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
)

__all__ = [
"SuccessiveHalving",
"SuccessiveHalvingWithPriors",
"IFBO",
"MOBSTER",
"AsynchronousHyperband",
"AsynchronousHyperbandWithPriors",
"AsynchronousSuccessiveHalving",
"AsynchronousSuccessiveHalvingWithPriors",
"Hyperband",
"HyperbandWithPriors",
"HyperbandCustomDefault",
"AsynchronousHyperband",
"AsynchronousHyperbandWithPriors",
"MOBSTER",
"IFBO",
"HyperbandWithPriors",
"SuccessiveHalving",
"SuccessiveHalvingWithPriors",
]
2 changes: 1 addition & 1 deletion neps/optimizers/multi_fidelity_prior/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from neps.optimizers.multi_fidelity_prior.priorband import PriorBand

__all__ = [
"PriorBand",
"PriorBandAsha",
"PriorBandAshaHB",
"PriorBand",
]
4 changes: 3 additions & 1 deletion neps/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ def _get_next_trial(self) -> Trial | Literal["break"]:
time_started=time.time(),
worker_id=self.worker_id,
)
self.state._trial_repo.update_trial(earliest_pending, hints="metadata")
self.state._trial_repo.update_trial(
earliest_pending, hints="metadata"
)
logger.info(
"Worker '%s' picked up pending trial: %s.",
self.worker_id,
Expand Down
2 changes: 1 addition & 1 deletion neps/sampling/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from neps.sampling.priors import CenteredPrior, Prior, UniformPrior
from neps.sampling.samplers import Sampler, Sobol

__all__ = ["Sobol", "Sampler", "Prior", "UniformPrior", "CenteredPrior"]
__all__ = ["CenteredPrior", "Prior", "Sampler", "Sobol", "UniformPrior"]
10 changes: 5 additions & 5 deletions neps/search_spaces/hyperparameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

__all__ = [
"Categorical",
"Constant",
"Integer",
"Float",
"Numerical",
"CategoricalParameter",
"Constant",
"ConstantParameter",
"IntegerParameter",
"Float",
"FloatParameter",
"Integer",
"IntegerParameter",
"Numerical",
"NumericalParameter",
]
2 changes: 1 addition & 1 deletion neps/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from neps.state.trial import Trial

__all__ = [
"SeedSnapshot",
"BudgetInfo",
"OptimizationState",
"OptimizerInfo",
"SeedSnapshot",
"Trial",
]
6 changes: 1 addition & 5 deletions neps/state/neps_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from dataclasses import dataclass, field
from pathlib import Path
from typing import (
TYPE_CHECKING,
Literal,
TypeAlias,
TypeVar,
Expand All @@ -43,13 +42,10 @@
ReaderWriterTrial,
TrialWriteHint,
)
from neps.state.optimizer import OptimizerInfo
from neps.state.optimizer import OptimizationState, OptimizerInfo
from neps.state.trial import Report, Trial
from neps.utils.files import atomic_write, deserialize, serialize

if TYPE_CHECKING:
from neps.state.optimizer import OptimizationState

logger = logging.getLogger(__name__)


Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ keywords = [
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
Expand Down Expand Up @@ -214,7 +214,7 @@ ignore = [
"S101", # Use of assert detected.
"W292", # No newline at end of file
"PLC1901", # "" can be simplified to be falsey
"TCH003", # Move stdlib import into TYPE_CHECKING
"TC003", # Move stdlib import into TYPE_CHECKING
"B010", # Do not use `setattr`
"PD901", # Use a better name than 'df'
"PD011", # Use .to_numpy() instead of .values (triggers on report.values)
Expand Down
40 changes: 21 additions & 19 deletions tests/joint_config_space.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import ConfigSpace as CS
from jahs_bench.lib.core.constants import Activations

Expand All @@ -16,37 +18,37 @@
"Op1",
choices=list(range(5)),
default_value=0,
meta=dict(help="The operation on the first edge of the cell."),
meta={"help": "The operation on the first edge of the cell."},
),
CS.CategoricalHyperparameter(
"Op2",
choices=list(range(5)),
default_value=0,
meta=dict(help="The operation on the second edge of the cell."),
meta={"help": "The operation on the second edge of the cell."},
),
CS.CategoricalHyperparameter(
"Op3",
choices=list(range(5)),
default_value=0,
meta=dict(help="The operation on the third edge of the cell."),
meta={"help": "The operation on the third edge of the cell."},
),
CS.CategoricalHyperparameter(
"Op4",
choices=list(range(5)),
default_value=0,
meta=dict(help="The operation on the fourth edge of the cell."),
meta={"help": "The operation on the fourth edge of the cell."},
),
CS.CategoricalHyperparameter(
"Op5",
choices=list(range(5)),
default_value=0,
meta=dict(help="The operation on the fifth edge of the cell."),
meta={"help": "The operation on the fifth edge of the cell."},
),
CS.CategoricalHyperparameter(
"Op6",
choices=list(range(5)),
default_value=0,
meta=dict(help="The operation on the sixth edge of the cell."),
meta={"help": "The operation on the sixth edge of the cell."},
),
# CS.OrdinalHyperparameter("Resolution", sequence=[0.25, 0.5, 1.], default_value=1.,
# meta=dict(help="The sample resolution of the input images w.r.t. one side of the "
Expand All @@ -57,21 +59,21 @@
"TrivialAugment",
choices=[True, False],
default_value=False,
meta=dict(
help="Controls whether or not TrivialAugment is used for pre-processing "
meta={
"help": "Controls whether or not TrivialAugment is used for pre-processing "
"data. If False (default), a set of manually chosen transforms is "
"applied during pre-processing. If True, these are skipped in favor of "
"applying random transforms selected by TrivialAugment."
),
},
),
CS.CategoricalHyperparameter(
"Activation",
choices=list(Activations.__members__.keys()),
default_value="ReLU",
meta=dict(
help="Which activation function is to be used for the network. "
meta={
"help": "Which activation function is to be used for the network. "
"Default is ReLU."
),
},
),
]
)
Expand All @@ -81,31 +83,31 @@
"Optimizer",
choices=["SGD"],
default_value="SGD",
meta=dict(
help="Which optimizer to use for training this model. "
meta={
"help": "Which optimizer to use for training this model. "
"This is just a placeholder for now, to be used "
"properly in future versions."
),
},
)
lr = CS.UniformFloatHyperparameter(
"LearningRate",
lower=1e-3,
upper=1e0,
default_value=1e-1,
log=True,
meta=dict(
help="The learning rate for the optimizer used during model training. In the "
meta={
"help": "The learning rate for the optimizer used during model training. In the "
"case of adaptive learning rate optimizers such as Adam, this is the "
"initial learning rate."
),
},
)
weight_decay = CS.UniformFloatHyperparameter(
"WeightDecay",
lower=1e-5,
upper=1e-2,
default_value=5e-4,
log=True,
meta=dict(help="Weight decay to be used by the " "optimizer during model training."),
meta={"help": "Weight decay to be used by the " "optimizer during model training."},
)

joint_config_space.add_hyperparameters([optimizers, lr, weight_decay])
Loading

0 comments on commit b764ccf

Please sign in to comment.