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