def test_evaluate_2(self): kernel = LinearKernel(2) assert kernel.evaluate(0) == 0 D = np.random.rand(10) assert np.all(kernel.evaluate(D) == 2 * D) D = np.random.rand(10, 2) assert np.all(kernel.evaluate(D) == 2 * D)
def test_to_dict(self): kernel = LinearKernel(1) output_dict = kernel.to_dict() assert "class" in output_dict assert output_dict["class"] == "LinearKernel" assert "param" in output_dict assert output_dict["param"] == 1
def test_derivatives_2(self): kernel = LinearKernel(2) D = np.random.rand(10) assert np.all(kernel.derivatives(D) == 2 * np.ones_like(D)) D = np.random.rand(10, 2) assert np.all(kernel.derivatives(D) == 2 * np.ones_like(D))
def test_dmin(self): kernel = LinearKernel(1) assert kernel.dmin == 0
def test___init__default(self): kernel = LinearKernel() assert kernel._param == 1
def test___init__(self): kernel = LinearKernel(param=2) assert kernel._param == 2