File: test_benchmarks.py

package info (click to toggle)
scikit-optimize 0.10.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,672 kB
  • sloc: python: 10,659; javascript: 438; makefile: 136; sh: 6
file content (22 lines) | stat: -rw-r--r-- 638 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np
import pytest
from numpy.testing import assert_almost_equal, assert_array_almost_equal

from skopt.benchmarks import branin, hart6


@pytest.mark.fast_test
def test_branin():
    xstars = np.asarray([(-np.pi, 12.275), (+np.pi, 2.275), (9.42478, 2.475)])
    f_at_xstars = np.asarray([branin(xstar) for xstar in xstars])
    branin_min = np.array([0.397887] * xstars.shape[0])
    assert_array_almost_equal(f_at_xstars, branin_min)


@pytest.mark.fast_test
def test_hartmann6():
    assert_almost_equal(
        hart6((0.20169, 0.15001, 0.476874, 0.275332, 0.311652, 0.6573)),
        -3.32237,
        decimal=5,
    )