Skip to content

Commit dbace7a

Browse files
support numpy 2.0
1 parent 85da990 commit dbace7a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

kernel_tuner/strategies/bayes_opt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def get_hyperparam(name: str, default, supported_values=list()):
235235
self.invalid_value = 1e20
236236
self.opt_direction = opt_direction
237237
if opt_direction == "min":
238-
self.worst_value = np.PINF
238+
self.worst_value = np.inf
239239
self.argopt = np.argmin
240240
elif opt_direction == "max":
241241
self.worst_value = np.NINF
@@ -262,7 +262,7 @@ def get_hyperparam(name: str, default, supported_values=list()):
262262
self.__visited_num = 0
263263
self.__visited_valid_num = 0
264264
self.__visited_searchspace_indices = [False] * self.searchspace_size
265-
self.__observations = [np.NaN] * self.searchspace_size
265+
self.__observations = [np.nan] * self.searchspace_size
266266
self.__valid_observation_indices = [False] * self.searchspace_size
267267
self.__valid_params = list()
268268
self.__valid_observations = list()
@@ -311,7 +311,7 @@ def is_not_visited(self, index: int) -> bool:
311311

312312
def is_valid(self, observation: float) -> bool:
313313
"""Returns whether an observation is valid."""
314-
return not (observation is None or observation == self.invalid_value or observation == np.NaN)
314+
return not (observation is None or observation == self.invalid_value or observation == np.nan)
315315

316316
def get_af_by_name(self, name: str):
317317
"""Get the basic acquisition functions by their name."""

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ priority = "explicit"
6565
# ATTENTION: if anything is changed here, run `poetry update`
6666
[tool.poetry.dependencies]
6767
python = ">=3.9,<4" # <4 is because of hip-python # NOTE when changing the supported Python versions, also change the test versions in the noxfile
68-
numpy = "^1.26.0" # Python 3.12 requires numpy at least 1.26
68+
numpy = "^2.2.4" # Python 3.12 requires numpy at least 1.26
6969
scipy = ">=1.11.0" # held back by Python 3.9
7070
packaging = "*" # required by file_utils
7171
jsonschema = "*"
@@ -153,4 +153,4 @@ select = [
153153
"D", # pydocstyle,
154154
]
155155
[tool.ruff.pydocstyle]
156-
convention = "google"
156+
convention = "google"

test/strategies/test_bayesian_optimization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_bo_initialization():
7474
assert BO.searchspace == pruned_parameter_space
7575
assert BO.unvisited_cache == pruned_parameter_space
7676
assert len(BO.observations) == len(pruned_parameter_space)
77-
assert BO.current_optimum == np.PINF
77+
assert BO.current_optimum == np.inf
7878

7979
def test_bo_initial_sample_lhs():
8080
sample = BO.draw_latin_hypercube_samples(num_samples=1)

0 commit comments

Comments
 (0)