def test_evaluate_1(self): kernel = MultiQuadraticKernel(1) assert kernel.evaluate(np.array([0])) == 1 D = np.random.rand(10) assert np.all(kernel.evaluate(D) == np.sqrt(D**2 + np.ones_like(D))) D = np.random.rand(10, 2) assert np.all(kernel.evaluate(D) == np.sqrt(D**2 + np.ones_like(D)))
def test_to_dict(self): kernel = MultiQuadraticKernel(1) output_dict = kernel.to_dict() assert "class" in output_dict assert output_dict["class"] == "MultiQuadraticKernel" assert "param" in output_dict assert output_dict["param"] == 1
def test_derivatives_1(self): kernel = MultiQuadraticKernel(1) D = np.random.rand(10) assert np.all( kernel.derivatives(D) == D / np.sqrt(D**2 + np.ones_like(D))) D = np.random.rand(10, 2) assert np.all( kernel.derivatives(D) == D / np.sqrt(D**2 + np.ones_like(D)))
def test_dmin(self): kernel = MultiQuadraticKernel(1) assert kernel.dmin == 0
def test___init__default(self): kernel = MultiQuadraticKernel() assert kernel._param == 1
def test___init__(self): kernel = MultiQuadraticKernel(param=2) assert kernel._param == 2