def test_gp_nonfinite_phenotype(): random = RandomState(94584) N = 50 X = random.randn(N, 100) offset = 0.5 mean = OffsetMean(N) mean.offset = offset mean.fix_offset() cov = LinearCov(X) cov.scale = 1.0 y = zeros(N) y[0] = nan with pytest.raises(ValueError): GP(y, mean, cov) y[0] = -inf with pytest.raises(ValueError): GP(y, mean, cov) y[0] = +inf with pytest.raises(ValueError): GP(y, mean, cov)
def test_gp_value_1(): random = RandomState(94584) N = 50 X = random.randn(N, 100) offset = 0.5 mean = OffsetMean(N) mean.offset = offset mean.fix_offset() cov = LinearCov(X) cov.scale = 1.0 y = random.randn(N) gp = GP(y, mean, cov) assert_allclose(gp.value(), -153.623791551399108)
def test_gp_gradient(): random = RandomState(94584) N = 50 X = random.randn(N, 100) offset = 0.5 mean = OffsetMean(N) mean.offset = offset mean.fix_offset() cov = LinearCov(X) cov.scale = 1.0 y = random.randn(N) gp = GP(y, mean, cov) assert_allclose(gp._check_grad(), 0, atol=1e-5)
def test_gp_maximize(): random = RandomState(94584) N = 50 X = random.randn(N, 100) offset = 0.5 mean = OffsetMean(N) mean.offset = offset mean.fix_offset() cov = LinearCov(X) cov.scale = 1.0 y = random.randn(N) gp = GP(y, mean, cov) assert_allclose(gp.value(), -153.623791551) gp.fit(verbose=False) assert_allclose(gp.value(), -79.8992122415)