Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bayes_opt/target_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def __init__(
else:
self._constraint_values = np.empty(shape=(0, constraint.lb.size), dtype=float)

self._sorting_warning_already_shown = False # TODO: remove in future version

def __contains__(self, x: NDArray[Float]) -> bool:
"""Check if this parameter has already been registered.

Expand Down Expand Up @@ -330,6 +332,17 @@ def register(
>>> len(space)
1
"""
# TODO: remove in future version
if isinstance(params, np.ndarray) and not self._sorting_warning_already_shown:
msg = (
"You're attempting to register an np.ndarray. Currently, the optimizer internally sorts"
" parameters by key and expects any registered array to respect this order. In future"
" versions this behaviour will change and the order as given by the pbounds dictionary"
" will be used. If you wish to retain sorted parameters, please manually sort your pbounds"
" dictionary before constructing the optimizer."
)
warn(msg, stacklevel=1)
self._sorting_warning_already_shown = True
x = self._as_array(params)
if x in self:
if self._allow_duplicate_points:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bayesian-optimization"
version = "2.0.0"
version = "2.0.1"
description = "Bayesian Optimization package"
authors = ["Fernando Nogueira"]
license = "MIT"
Expand Down
Loading