Skip to content

Commit c8121c8

Browse files
committed
fix false positive rate tests
1 parent 85d2ba1 commit c8121c8

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
/*.pyc
99
/*.egg
1010
/*.egg-info
11-
.venv
12-
11+
.venv*
12+
/.serena
1313
# Notebook checkpoints
1414
.ipynb_checkpoints
1515

tests/lc2st_test.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ def _create_npe(num_simulations, max_epochs=None):
3838
inference = NPE(prior, density_estimator='maf')
3939
inference = inference.append_simulations(theta=theta_train, x=x_train)
4040

41-
train_kwargs = {"training_batch_size": 100}
42-
if max_epochs:
43-
train_kwargs["max_num_epochs"] = max_epochs
44-
45-
return inference.train(**train_kwargs)
41+
return inference.train(
42+
max_num_epochs=2**31 - 1 if max_epochs is None else max_epochs,
43+
)
4644

4745
return _create_npe
4846

@@ -54,7 +52,7 @@ def badly_trained_npe(npe_factory):
5452

5553
@pytest.fixture(scope="session")
5654
def well_trained_npe(npe_factory):
57-
return npe_factory(num_simulations=10_000)
55+
return npe_factory(num_simulations=5_000)
5856

5957

6058
@pytest.fixture(scope="session")
@@ -276,7 +274,7 @@ def test_lc2st_false_positiv_rate(method, basic_setup, well_trained_npe, set_see
276274
proportion_rejected = torch.tensor(results).float().mean()
277275

278276
assert proportion_rejected < (1 - confidence_level), (
279-
f"LC2ST p-values too small, test should be rejected \
280-
less then {(1 - confidence_level) * 100}% of the time, \
281-
but was rejected {proportion_rejected * 100}% of the time."
277+
"LC2ST p-values too small, test should be rejected "
278+
f"less then {(1 - confidence_level) * 100.0:<.2f}% of the time, "
279+
f"but was rejected {proportion_rejected * 100.0:<.2f}% of the time."
282280
)

0 commit comments

Comments
 (0)