Skip to content

Commit ece0719

Browse files
Merge pull request #295 from KernelTuner/numpy2-support
Numpy2 support
2 parents 85da990 + e7d6a84 commit ece0719

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
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.0.0" # 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/context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555

5656
try:
5757
from hip import hip
58+
hip.hipDriverGetVersion()
5859
hip_present = True
59-
except ImportError:
60+
except (ImportError, RuntimeError):
6061
hip_present = False
6162

6263
skip_if_no_pycuda = pytest.mark.skipif(
@@ -78,7 +79,7 @@
7879
)
7980
skip_if_no_openmp = pytest.mark.skipif(not openmp_present, reason="No OpenMP found")
8081
skip_if_no_openacc = pytest.mark.skipif(not openacc_present, reason="No nvc++ on PATH")
81-
skip_if_no_hip = pytest.mark.skipif(not hip_present, reason="No HIP Python found")
82+
skip_if_no_hip = pytest.mark.skipif(not hip_present, reason="No HIP Python found or no HIP device detected")
8283

8384

8485
def skip_backend(backend: str):

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)