|
25 | 25 | from pymc.math import cartesian |
26 | 26 |
|
27 | 27 |
|
28 | | -class TestSigmaParams: |
29 | | - def setup_method(self): |
30 | | - """Common setup.""" |
31 | | - self.x = np.linspace(-5, 5, 30)[:, None] |
32 | | - self.xu = np.linspace(-5, 5, 10)[:, None] |
33 | | - self.y = np.random.normal(0.25 * self.x, 0.1) |
34 | | - |
35 | | - with pm.Model() as self.model: |
36 | | - cov_func = pm.gp.cov.Linear(1, c=0.0) |
37 | | - c = pm.Normal("c", mu=20.0, sigma=100.0) |
38 | | - mean_func = pm.gp.mean.Constant(c) |
39 | | - self.gp = self.gp_implementation(mean_func=mean_func, cov_func=cov_func) |
40 | | - self.sigma = pm.HalfNormal("sigma", sigma=100) |
41 | | - |
42 | | - |
43 | | -class TestMarginalSigmaParams(TestSigmaParams): |
44 | | - R"""Tests for the deprecation warnings and raising ValueError.""" |
45 | | - |
46 | | - gp_implementation = pm.gp.Marginal |
47 | | - |
48 | | - def test_catch_warnings(self): |
49 | | - """Warning from using the old noise parameter.""" |
50 | | - with self.model: |
51 | | - with pytest.warns(FutureWarning): |
52 | | - self.gp.marginal_likelihood("lik_noise", X=self.x, y=self.y, noise=self.sigma) |
53 | | - |
54 | | - with pytest.warns(FutureWarning): |
55 | | - self.gp.conditional( |
56 | | - "cond_noise", |
57 | | - Xnew=self.x, |
58 | | - given={ |
59 | | - "noise": self.sigma, |
60 | | - }, |
61 | | - ) |
62 | | - |
63 | | - def test_raise_value_error(self): |
64 | | - """Either both or neither parameter is specified.""" |
65 | | - with self.model: |
66 | | - with pytest.raises(ValueError): |
67 | | - self.gp.marginal_likelihood( |
68 | | - "like_both", X=self.x, y=self.y, noise=self.sigma, sigma=self.sigma |
69 | | - ) |
70 | | - |
71 | | - with pytest.raises(ValueError): |
72 | | - self.gp.marginal_likelihood("like_neither", X=self.x, y=self.y) |
73 | | - |
74 | | - |
75 | | -class TestMarginalApproxSigmaParams(TestSigmaParams): |
76 | | - R"""Tests for the deprecation warnings and raising ValueError""" |
77 | | - |
78 | | - gp_implementation = pm.gp.MarginalApprox |
79 | | - |
80 | | - @pytest.mark.xfail(reason="Possible shape problem, see #6366") |
81 | | - def test_catch_warnings(self): |
82 | | - """Warning from using the old noise parameter.""" |
83 | | - with self.model: |
84 | | - with pytest.warns(FutureWarning): |
85 | | - self.gp.marginal_likelihood( |
86 | | - "lik_noise", X=self.x, Xu=self.xu, y=self.y, noise=self.sigma |
87 | | - ) |
88 | | - |
89 | | - def test_raise_value_error(self): |
90 | | - """Either both or neither parameter is specified.""" |
91 | | - with self.model: |
92 | | - with pytest.raises(ValueError): |
93 | | - self.gp.marginal_likelihood( |
94 | | - "like_both", |
95 | | - X=self.x, |
96 | | - Xu=self.xu, |
97 | | - y=self.y, |
98 | | - noise=self.sigma, |
99 | | - sigma=self.sigma, |
100 | | - ) |
101 | | - |
102 | | - with pytest.raises(ValueError): |
103 | | - self.gp.marginal_likelihood("like_neither", X=self.x, Xu=self.xu, y=self.y) |
104 | | - |
105 | | - |
106 | 28 | class TestMarginalVsMarginalApprox: |
107 | 29 | R""" |
108 | 30 | Compare test fits of models Marginal and MarginalApprox. |
|
0 commit comments