示例#1
0
 def test_evaluate_2(self):
     kernel = InverseQuadraticKernel(2)
     assert kernel.evaluate(np.array([0])) == 1
     D = np.random.rand(10)
     assert np.all(kernel.evaluate(D) == (4 * D**2 + np.ones_like(D))**(-1))
     D = np.random.rand(10, 2)
     assert np.all(kernel.evaluate(D) == (4 * D**2 + np.ones_like(D))**(-1))
示例#2
0
 def test_to_dict(self):
     kernel = InverseQuadraticKernel(1)
     output_dict = kernel.to_dict()
     assert "class" in output_dict
     assert output_dict["class"] == "InverseQuadraticKernel"
     assert "param" in output_dict
     assert output_dict["param"] == 1
示例#3
0
 def test_derivatives_2(self):
     kernel = InverseQuadraticKernel(2)
     D = np.random.rand(10)
     assert np.all(
         kernel.derivatives(D) == -8 * D / (4 * D**2 + np.ones_like(D))**2)
     D = np.random.rand(10, 2)
     assert np.all(
         kernel.derivatives(D) == -8 * D / (4 * D**2 + np.ones_like(D))**2)
示例#4
0
 def test_dmin(self):
     kernel = InverseQuadraticKernel(1)
     assert kernel.dmin == -1
示例#5
0
 def test___init__default(self):
     kernel = InverseQuadraticKernel()
     assert kernel._param == 1
示例#6
0
 def test___init__(self):
     kernel = InverseQuadraticKernel(param=2)
     assert kernel._param == 2