Skip to content

Commit a68d727

Browse files
committed
remove unnecessary files, have acquisition baseclass functions raise errors
1 parent d0ef58a commit a68d727

File tree

4 files changed

+31
-1416
lines changed

4 files changed

+31
-1416
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ docsrc/*.ipynb
3636
docsrc/static/*
3737
docsrc/README.md
3838

39-
poetry.lock
39+
poetry.lock
40+
41+
# Add log files and optimizer state files to gitignore
42+
examples/logs.log
43+
examples/optimizer_state.json

bayes_opt/acquisition.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,42 @@ def _deserialize_random_state(self, state_dict: dict | None) -> None:
100100
def base_acq(self, *args: Any, **kwargs: Any) -> NDArray[Float]:
101101
"""Provide access to the base acquisition function."""
102102

103-
def get_acquisition_params(self) -> dict[str, Any]:
104-
"""Get the acquisition function parameters.
103+
def _fit_gp(self, gp: GaussianProcessRegressor, target_space: TargetSpace) -> None:
104+
# Sklearn's GP throws a large number of warnings at times, but
105+
# we don't really need to see them here.
106+
with warnings.catch_warnings():
107+
warnings.simplefilter("ignore")
108+
gp.fit(target_space.params, target_space.target)
109+
if target_space.constraint is not None:
110+
target_space.constraint.fit(target_space.params, target_space._constraint_values)
111+
112+
def get_acquisition_params(self):
113+
"""
114+
Get the parameters of the acquisition function.
105115
106116
Returns
107117
-------
108118
dict
109-
Dictionary containing the acquisition function parameters.
110-
All values must be JSON serializable.
119+
The parameters of the acquisition function.
111120
"""
112-
return {}
121+
error_msg = (
122+
"Custom AcquisitionFunction subclasses must implement their own get_acquisition_params method."
123+
)
124+
raise NotImplementedError(error_msg)
113125

114-
def set_acquisition_params(self, params: dict) -> None:
115-
"""Set the acquisition function parameters.
126+
def set_acquisition_params(self, **params):
127+
"""
128+
Set the parameters of the acquisition function.
116129
117130
Parameters
118131
----------
119-
params : dict
120-
Dictionary containing the acquisition function parameters.
132+
**params : dict
133+
The parameters of the acquisition function.
121134
"""
122-
return {}
135+
error_msg = (
136+
"Custom AcquisitionFunction subclasses must implement their own set_acquisition_params method."
137+
)
138+
raise NotImplementedError(error_msg)
123139

124140
def suggest(
125141
self,
@@ -168,15 +184,6 @@ def suggest(
168184
acq = self._get_acq(gp=gp, constraint=target_space.constraint)
169185
return self._acq_min(acq, target_space, n_random=n_random, n_l_bfgs_b=n_l_bfgs_b)
170186

171-
def _fit_gp(self, gp: GaussianProcessRegressor, target_space: TargetSpace) -> None:
172-
# Sklearn's GP throws a large number of warnings at times, but
173-
# we don't really need to see them here.
174-
with warnings.catch_warnings():
175-
warnings.simplefilter("ignore")
176-
gp.fit(target_space.params, target_space.target)
177-
if target_space.constraint is not None:
178-
target_space.constraint.fit(target_space.params, target_space._constraint_values)
179-
180187
def _get_acq(
181188
self, gp: GaussianProcessRegressor, constraint: ConstraintModel | None = None
182189
) -> Callable[[NDArray[Float]], NDArray[Float]]:

examples/logs.log

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)