Skip to content

Commit

Permalink
Update unit tests to work with new higher-dim SobolEngine
Browse files Browse the repository at this point in the history
Summary: Account for the new capabilities of the pytorch SobolEngine (up to 21201 dims) from scipy/scipy#10844

Differential Revision: D25661131

fbshipit-source-id: de53b82c1a5a8d4bcba21cd72bbd1ccb0eec0164
  • Loading branch information
Balandat authored and facebook-github-bot committed Jan 30, 2021
1 parent 16ea705 commit 65662a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion test/acquisition/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,9 @@ def test_prune_inferior_points(self):
new_callable=mock.PropertyMock,
)
)
mock_event_shape.return_value = torch.Size([1, 1, 1112])
mock_event_shape.return_value = torch.Size(
[1, 1, torch.quasirandom.SobolEngine.MAXDIM + 1]
)
es.enter_context(
mock.patch.object(MockPosterior, "rsample", return_value=samples)
)
Expand Down
7 changes: 4 additions & 3 deletions test/sampling/test_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,11 @@ def test_forward_no_collapse(self):

def test_unsupported_dimension(self):
sampler = SobolQMCNormalSampler(num_samples=2)
mean = torch.zeros(1112)
cov = DiagLazyTensor(torch.ones(1112))
maxdim = torch.quasirandom.SobolEngine.MAXDIM + 1
mean = torch.zeros(maxdim)
cov = DiagLazyTensor(torch.ones(maxdim))
mvn = MultivariateNormal(mean, cov)
posterior = GPyTorchPosterior(mvn)
with self.assertRaises(UnsupportedError) as e:
sampler(posterior)
self.assertIn("Requested: 1112", str(e.exception))
self.assertIn(f"Requested: {maxdim}", str(e.exception))

0 comments on commit 65662a9

Please sign in to comment.