def test_input_transform(): # Test construction: p = GP(lambda x: x**2, Linear()) assert (str(p.transform(lambda x: x)) == "GP(<lambda> transform <lambda>, Linear() transform <lambda>)") # Test case: p_transformed = p.transform(lambda x: B.sqrt(x)) x = B.linspace(0, 5, 10) y = p_transformed(x).sample() post = p.measure | (p_transformed(x, B.epsilon), y) assert_equal_normals(post(p(B.sqrt(x))), post(p_transformed(x))) assert_equal_normals(post(p(x)), post(p_transformed(x * x)))
def test_input_transform(): # Test construction: p = GP(TensorProductMean(lambda x: x**2), EQ()) assert (str(p.transform(lambda x: x)) == "GP(<lambda> transform <lambda>, EQ() transform <lambda>)") # Test case: p = GP(EQ()) p_transformed = p.transform(lambda x: B.sqrt(x)) x = B.linspace(0, 5, 10) y = p_transformed(x).sample() post = p.measure | (p_transformed(x), y) assert_equal_normals(post(p(B.sqrt(x))), post(p_transformed(x))) assert_equal_normals(post(p(x)), post(p_transformed(x * x)))