|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +import re |
3 | 4 | import sys |
4 | 5 |
|
5 | 6 | import numpy as np |
@@ -403,66 +404,66 @@ def test_gphedge_integration(gp, target_space, random_state): |
403 | 404 |
|
404 | 405 | @pytest.mark.parametrize("kappa", [-1.0, -sys.float_info.epsilon, -np.inf]) |
405 | 406 | 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.")): |
407 | 408 | acquisition.UpperConfidenceBound(kappa=kappa) |
408 | 409 |
|
409 | 410 |
|
410 | 411 | @pytest.mark.parametrize("exploration_decay", [-0.1, 0.0, 1.1, 2.0, np.inf]) |
411 | 412 | def test_upper_confidence_bound_invalid_exploration_decay_error(exploration_decay: float): |
412 | 413 | 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.") |
414 | 415 | ): |
415 | 416 | acquisition.UpperConfidenceBound(kappa=1.0, exploration_decay=exploration_decay) |
416 | 417 |
|
417 | 418 |
|
418 | 419 | @pytest.mark.parametrize("exploration_decay_delay", [-1, -10, "not_an_int", 1.5]) |
419 | 420 | def test_upper_confidence_bound_invalid_exploration_decay_delay_error(exploration_decay_delay): |
420 | 421 | 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.") |
422 | 423 | ): |
423 | 424 | acquisition.UpperConfidenceBound(kappa=1.0, exploration_decay_delay=exploration_decay_delay) |
424 | 425 |
|
425 | 426 |
|
426 | 427 | @pytest.mark.parametrize("xi", [-0.1, -1.0, -np.inf]) |
427 | 428 | 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.")): |
429 | 430 | acquisition.ProbabilityOfImprovement(xi=xi) |
430 | 431 |
|
431 | 432 |
|
432 | 433 | @pytest.mark.parametrize("exploration_decay", [-0.1, 0.0, 1.1, 2.0, np.inf]) |
433 | 434 | def test_probability_of_improvement_invalid_exploration_decay_error(exploration_decay: float): |
434 | 435 | 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.") |
436 | 437 | ): |
437 | 438 | acquisition.ProbabilityOfImprovement(xi=0.01, exploration_decay=exploration_decay) |
438 | 439 |
|
439 | 440 |
|
440 | 441 | @pytest.mark.parametrize("exploration_decay_delay", [-1, -10, "not_an_int", 1.5]) |
441 | 442 | def test_probability_of_improvement_invalid_exploration_decay_delay_error(exploration_decay_delay): |
442 | 443 | 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.") |
444 | 445 | ): |
445 | 446 | acquisition.ProbabilityOfImprovement(xi=0.01, exploration_decay_delay=exploration_decay_delay) |
446 | 447 |
|
447 | 448 |
|
448 | 449 | @pytest.mark.parametrize("xi", [-0.1, -1.0, -np.inf]) |
449 | 450 | 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.")): |
451 | 452 | acquisition.ExpectedImprovement(xi=xi) |
452 | 453 |
|
453 | 454 |
|
454 | 455 | @pytest.mark.parametrize("exploration_decay", [-0.1, 0.0, 1.1, 2.0, np.inf]) |
455 | 456 | def test_expected_improvement_invalid_exploration_decay_error(exploration_decay: float): |
456 | 457 | 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.") |
458 | 459 | ): |
459 | 460 | acquisition.ExpectedImprovement(xi=0.01, exploration_decay=exploration_decay) |
460 | 461 |
|
461 | 462 |
|
462 | 463 | @pytest.mark.parametrize("exploration_decay_delay", [-1, -10, "not_an_int", 1.5]) |
463 | 464 | def test_expected_improvement_invalid_exploration_decay_delay_error(exploration_decay_delay): |
464 | 465 | 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.") |
466 | 467 | ): |
467 | 468 | acquisition.ExpectedImprovement(xi=0.01, exploration_decay_delay=exploration_decay_delay) |
468 | 469 |
|
|
0 commit comments