예제 #1
0
 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)
예제 #2
0
 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
예제 #3
0
 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))
예제 #4
0
 def test_dmin(self):
     kernel = LinearKernel(1)
     assert kernel.dmin == 0
예제 #5
0
 def test___init__default(self):
     kernel = LinearKernel()
     assert kernel._param == 1
예제 #6
0
 def test___init__(self):
     kernel = LinearKernel(param=2)
     assert kernel._param == 2