Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/*.pyc
/*.egg
/*.egg-info
.venv

.venv*
/.serena
# Notebook checkpoints
.ipynb_checkpoints

Expand Down
18 changes: 8 additions & 10 deletions tests/lc2st_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ def _create_npe(num_simulations, max_epochs=None):
inference = NPE(prior, density_estimator='maf')
inference = inference.append_simulations(theta=theta_train, x=x_train)

train_kwargs = {"training_batch_size": 100}
if max_epochs:
train_kwargs["max_num_epochs"] = max_epochs

return inference.train(**train_kwargs)
return inference.train(
max_num_epochs=2**31 - 1 if max_epochs is None else max_epochs,
)

return _create_npe


@pytest.fixture(scope="session")
def badly_trained_npe(npe_factory):
return npe_factory(num_simulations=100, max_epochs=1)
return npe_factory(num_simulations=50, max_epochs=1)


@pytest.fixture(scope="session")
def well_trained_npe(npe_factory):
return npe_factory(num_simulations=10_000)
return npe_factory(num_simulations=5_000)


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

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