Skip to content

Commit

Permalink
Merge branch 'code_scanning_alerts' of github.com:UCL-CCS/EasyVVUQ in…
Browse files Browse the repository at this point in the history
…to code_scanning_alerts
  • Loading branch information
DavidPCoster committed Dec 4, 2023
2 parents 232d1e9 + 39911e1 commit 2cc076c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/test_analysis_qmc_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_analyse():
"a": cp.Uniform(0.0, 1.0),
"b": cp.Uniform(0.0, 1.0)
}
sampler = QMCSampler(vary, 100)
sampler = QMCSampler(vary, 128)
samples = {('run_id', 0): [], ('a', 0): [], ('b', 0): [], ('a+b', 0): []}
for i, sample in enumerate(sampler):
samples[('run_id', 0)].append(i)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_sampling_qmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

def test_init():
with pytest.raises(RuntimeError):
QMCSampler({}, 100)
QMCSampler({}, 128)
with pytest.raises(RuntimeError):
QMCSampler([], 100)
QMCSampler([], 128)


def test_is_finite():
vary = {'a': cp.Uniform(-5, 3), 'b': cp.Uniform(2, 10)}
sampler = QMCSampler(vary, 100)
sampler = QMCSampler(vary, 128)
assert (sampler.is_finite())


def test_sampling():
vary = {'a': cp.Uniform(-5, 0), 'b': cp.Uniform(2, 10)}
sampler = QMCSampler(vary, 100)
assert (sampler.n_samples == 400)
sampler = QMCSampler(vary, 128)
assert (sampler.n_samples == 512)
for _ in range(sampler.n_samples):
sample = next(sampler)
assert (sample['a'] >= -5 and sample['a'] <= 0)
Expand All @@ -30,8 +30,8 @@ def test_sampling():

def test_resume():
vary = {'a': cp.Uniform(-5, 0), 'b': cp.Uniform(2, 10)}
sampler = QMCSampler(vary, 100, 390)
for _ in range(10):
sampler = QMCSampler(vary, 128, 500)
for _ in range(12):
sample = next(sampler)
with pytest.raises(StopIteration):
next(sampler)

0 comments on commit 2cc076c

Please sign in to comment.