Skip to content

Commit 72f93ac

Browse files
authored
chore: update ruff (#614)
* fix: ruff error * update ruff
1 parent 2f697f8 commit 72f93ac

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dev = [
3838
"pre-commit>=3.7.1",
3939
"pytest>=8.0.0",
4040
"pytest-cov>=4.1.0",
41-
"ruff>=0.12.3",
41+
"ruff>=0.15.6",
4242
"sphinx-immaterial>=0.12.0",
4343
"sphinx>=7.0.0; python_version<'3.10'",
4444
"sphinx>=8.0.0; python_version>='3.10'",

tests/test_acquisition.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import re
34
import sys
45

56
import numpy as np
@@ -403,66 +404,66 @@ def test_gphedge_integration(gp, target_space, random_state):
403404

404405
@pytest.mark.parametrize("kappa", [-1.0, -sys.float_info.epsilon, -np.inf])
405406
def test_upper_confidence_bound_invalid_kappa_error(kappa: float):
406-
with pytest.raises(ValueError, match="kappa must be greater than or equal to 0."):
407+
with pytest.raises(ValueError, match=re.escape("kappa must be greater than or equal to 0.")):
407408
acquisition.UpperConfidenceBound(kappa=kappa)
408409

409410

410411
@pytest.mark.parametrize("exploration_decay", [-0.1, 0.0, 1.1, 2.0, np.inf])
411412
def test_upper_confidence_bound_invalid_exploration_decay_error(exploration_decay: float):
412413
with pytest.raises(
413-
ValueError, match="exploration_decay must be greater than 0 and less than or equal to 1."
414+
ValueError, match=re.escape("exploration_decay must be greater than 0 and less than or equal to 1.")
414415
):
415416
acquisition.UpperConfidenceBound(kappa=1.0, exploration_decay=exploration_decay)
416417

417418

418419
@pytest.mark.parametrize("exploration_decay_delay", [-1, -10, "not_an_int", 1.5])
419420
def test_upper_confidence_bound_invalid_exploration_decay_delay_error(exploration_decay_delay):
420421
with pytest.raises(
421-
ValueError, match="exploration_decay_delay must be an integer greater than or equal to 0."
422+
ValueError, match=re.escape("exploration_decay_delay must be an integer greater than or equal to 0.")
422423
):
423424
acquisition.UpperConfidenceBound(kappa=1.0, exploration_decay_delay=exploration_decay_delay)
424425

425426

426427
@pytest.mark.parametrize("xi", [-0.1, -1.0, -np.inf])
427428
def test_probability_of_improvement_invalid_xi_error(xi: float):
428-
with pytest.raises(ValueError, match="xi must be greater than or equal to 0."):
429+
with pytest.raises(ValueError, match=re.escape("xi must be greater than or equal to 0.")):
429430
acquisition.ProbabilityOfImprovement(xi=xi)
430431

431432

432433
@pytest.mark.parametrize("exploration_decay", [-0.1, 0.0, 1.1, 2.0, np.inf])
433434
def test_probability_of_improvement_invalid_exploration_decay_error(exploration_decay: float):
434435
with pytest.raises(
435-
ValueError, match="exploration_decay must be greater than 0 and less than or equal to 1."
436+
ValueError, match=re.escape("exploration_decay must be greater than 0 and less than or equal to 1.")
436437
):
437438
acquisition.ProbabilityOfImprovement(xi=0.01, exploration_decay=exploration_decay)
438439

439440

440441
@pytest.mark.parametrize("exploration_decay_delay", [-1, -10, "not_an_int", 1.5])
441442
def test_probability_of_improvement_invalid_exploration_decay_delay_error(exploration_decay_delay):
442443
with pytest.raises(
443-
ValueError, match="exploration_decay_delay must be an integer greater than or equal to 0."
444+
ValueError, match=re.escape("exploration_decay_delay must be an integer greater than or equal to 0.")
444445
):
445446
acquisition.ProbabilityOfImprovement(xi=0.01, exploration_decay_delay=exploration_decay_delay)
446447

447448

448449
@pytest.mark.parametrize("xi", [-0.1, -1.0, -np.inf])
449450
def test_expected_improvement_invalid_xi_error(xi: float):
450-
with pytest.raises(ValueError, match="xi must be greater than or equal to 0."):
451+
with pytest.raises(ValueError, match=re.escape("xi must be greater than or equal to 0.")):
451452
acquisition.ExpectedImprovement(xi=xi)
452453

453454

454455
@pytest.mark.parametrize("exploration_decay", [-0.1, 0.0, 1.1, 2.0, np.inf])
455456
def test_expected_improvement_invalid_exploration_decay_error(exploration_decay: float):
456457
with pytest.raises(
457-
ValueError, match="exploration_decay must be greater than 0 and less than or equal to 1."
458+
ValueError, match=re.escape("exploration_decay must be greater than 0 and less than or equal to 1.")
458459
):
459460
acquisition.ExpectedImprovement(xi=0.01, exploration_decay=exploration_decay)
460461

461462

462463
@pytest.mark.parametrize("exploration_decay_delay", [-1, -10, "not_an_int", 1.5])
463464
def test_expected_improvement_invalid_exploration_decay_delay_error(exploration_decay_delay):
464465
with pytest.raises(
465-
ValueError, match="exploration_decay_delay must be an integer greater than or equal to 0."
466+
ValueError, match=re.escape("exploration_decay_delay must be an integer greater than or equal to 0.")
466467
):
467468
acquisition.ExpectedImprovement(xi=0.01, exploration_decay_delay=exploration_decay_delay)
468469

tests/test_constraint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import re
4+
35
import numpy as np
46
import pytest
57
from scipy.optimize import NonlinearConstraint
@@ -163,5 +165,5 @@ def constraint_function_2_dim(x, y):
163165

164166
def test_null_constraint_function():
165167
constraint = ConstraintModel(None, np.array([0, 0]), np.array([1, 1]))
166-
with pytest.raises(ValueError, match="No constraint function was provided."):
168+
with pytest.raises(ValueError, match=re.escape("No constraint function was provided.")):
167169
constraint.eval()

tests/test_target_space.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import re
4+
35
import numpy as np
46
import pytest
57
from scipy.optimize import NonlinearConstraint
@@ -358,7 +360,7 @@ def test_set_bounds():
358360

359361
def test_no_target_func():
360362
target_space = TargetSpace(None, PBOUNDS)
361-
with pytest.raises(ValueError, match="No target function has been provided."):
363+
with pytest.raises(ValueError, match=re.escape("No target function has been provided.")):
362364
target_space.probe({"p1": 1, "p2": 2})
363365

364366

0 commit comments

Comments
 (0)