Skip to content

Commit 79ace7a

Browse files
committed
initital attempt to write unit test for _parameter_estimates
1 parent 1cab10d commit 79ace7a

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Plan:
3+
- Unit test:
4+
- _parameter_estimates: input and output weights are attached to the same samples
5+
- Integration test:
6+
- successful run of minimal version of the qoi using a deterministic model with importance sampling
7+
"""
8+
9+
# %%
10+
import torch
11+
from botorch.models.deterministic import GenericDeterministicModel
12+
13+
from axtreme.qoi.marginal_cdf_extrapolation import MarginalCDFExtrapolation
14+
15+
16+
def test_parameter_estimates_consistency_of_weights(gp_passthrough_1p: GenericDeterministicModel):
17+
importance_samples = torch.Tensor([1, 2, 3, 4])
18+
importance_weights = torch.Tensor([0.1, 0.2, 0.3, 0.4])
19+
20+
samples = [importance_samples, importance_weights]
21+
22+
env_sample = torch.tensor([[[0], [1], [2]]], dtype=torch.float64)
23+
qoi_estimator = MarginalCDFExtrapolation(env_iterable=env_sample, period_len=3)
24+
25+
posterior_samples, importance_weights_qoi = qoi_estimator._parameter_estimates(gp_passthrough_1p)
26+
27+
print(importance_samples, importance_weights)
28+
print(posterior_samples, importance_weights_qoi)
29+
30+
31+
# %%
32+
if __name__ == "__main__":
33+
import sys
34+
from pathlib import Path
35+
36+
root_dir = Path("../../")
37+
sys.path.append(str(root_dir))
38+
# from conftest import gp_passthrough_1p
39+
40+
test_parameter_estimates_consistency_of_weights(gp_passthrough_1p)
41+
42+
# %%

0 commit comments

Comments
 (0)