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