Skip to content

Commit d477cd4

Browse files
Merge branch 'stefanradev93:Development' into Development
2 parents 6db815a + 801e56f commit d477cd4

File tree

11 files changed

+24
-63
lines changed

11 files changed

+24
-63
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# From https://github.com/eeholmes/readthedoc-test/blob/main/.github/workflows/docs_pages.yml
22
name: docs
33

4-
# execute this workflow automatically when a we push to master
4+
# execute this workflow automatically when we push to master
55
on:
66
push:
77
branches:
@@ -28,7 +28,7 @@ jobs:
2828
uses: actions/setup-python@v4
2929
with:
3030
python-version: 3.11
31-
cache: 'pip'
31+
cache: "pip"
3232

3333
- name: Install dependencies
3434
run: |

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v3
10+
uses: actions/checkout@v4
1111
with:
1212
fetch-depth: 0
13-
- run: python3 -m pip install --upgrade build && python3 -m build
13+
- run: python3 -m pip install -U build && python3 -m build
1414
- name: Publish package
1515
uses: pypa/gh-action-pypi-publish@release/v1
1616
with:

.github/workflows/tests.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on:
44
pull_request:
55
push:
6-
branches:
6+
branches:
77
- master
88
- Development
99

@@ -14,17 +14,18 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, windows-latest]
17-
python-version: ['3.9']
17+
python-version: ["3.10", "3.11"]
1818

1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2121
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install dependencies
2626
run: |
27-
python -m pip install --upgrade pip
28-
pip install tox tox-gh-actions
27+
python -m ensurepip
28+
python -m pip install -U pip setuptools wheel
29+
python -m pip install tox tox-gh-actions
2930
- name: Test with tox
3031
run: tox

INSTALL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Full Installation Instructions
44
Requirements
55
------------
66

7-
This package requires Python 3.9 or later.
7+
This package requires Python 3.10 or later.
88
A simple installation is possible via `Miniconda <https://docs.conda.io/en/latest/miniconda.html>`_,
99
e.g. (on Linux)
1010

environment.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ no_implicit_reexport = true
2626

2727
[tool.black]
2828
line-length = 120
29-
target-version = ["py39", "py310"]
29+
target-version = ["py310", "py311"]
3030

3131
[tool.isort]
3232
profile = "black"

requirements_dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
flake8>=6.1.0
22
tox>=4.10.0
33
pytest>=7.2.0
4+
pytest-xdist>=3.5.0
45
pytest-cov>=4.1.0
56
myp>=1.5.1

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ keywords =
3030
model comparison
3131

3232
[options]
33-
python_requires = >=3.9
33+
python_requires = >=3.10
3434
packages = find:
3535
install_requires =
3636
h5py >= 3.7
@@ -51,6 +51,7 @@ testing =
5151
flake8 >= 3.9
5252
tox >= 3.24
5353
pytest >= 6.0
54+
pytest-xdist >= 2.4.0
5455
pytest-cov >= 2.10.0
5556
mypy >= 0.910
5657
docs =

tests/test_sensitivity.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
from copy import deepcopy
12
from functools import partial
23
from unittest.mock import MagicMock, Mock
34

45
import numpy as np
56
import pytest
67
import tensorflow as tf
78

8-
from copy import deepcopy
9-
109
from bayesflow import computational_utilities, sensitivity, simulation
1110
from tests.test_trainers import _create_training_setup, _prior, _simulator
1211

@@ -26,7 +25,7 @@ def _trainer_amortizer_sample_mock(input_dict, n_samples):
2625

2726

2827
class TestMisspecificationExperiment:
29-
def setup(self):
28+
def setup_method(self):
3029
self.trainer = _create_training_setup(mode="posterior")
3130

3231
# Mock the approximate posterior sampling of the amortizer, return np.ones of shape (n_sim, n_samples)

tests/test_trainers.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def _create_training_setup(mode):
6868
trainer = Trainer(generative_model=model, amortizer=amortizer)
6969
return trainer
7070

71+
7172
class TestTrainer:
72-
def setup(self):
73+
def setup_method(self):
7374
trainer_posterior = _create_training_setup("posterior")
7475
trainer_likelihood = _create_training_setup("likelihood")
7576
trainer_joint = _create_training_setup("joint")
@@ -111,7 +112,6 @@ def test_train_online(self, mode, reuse_optimizer, validation_sims):
111112
assert type(h["train_losses"]) is DataFrame
112113
assert type(h["val_losses"]) is DataFrame
113114

114-
115115
@pytest.mark.parametrize("mode", ["posterior", "joint"])
116116
@pytest.mark.parametrize("reuse_optimizer", [True, False])
117117
@pytest.mark.parametrize("validation_sims", [20, None])
@@ -202,34 +202,3 @@ def test_train_rounds(self, mode, reuse_optimizer, validation_sims):
202202
assert type(h) is dict
203203
assert type(h["train_losses"]) is DataFrame
204204
assert type(h["val_losses"]) is DataFrame
205-
206-
@pytest.mark.parametrize("reference_data", [None, "dict", "numpy"])
207-
@pytest.mark.parametrize("observed_data_type", ["dict", "numpy"])
208-
@pytest.mark.parametrize("bootstrap", [True, False])
209-
def mmd_hypothesis_test_no_reference(self, reference_data, observed_data_type, bootstrap):
210-
trainer = self.trainers["posterior"]
211-
_ = trainer.train_online(epochs=1, iterations_per_epoch=1, batch_size=4)
212-
213-
num_reference_simulations = 10
214-
num_observed_simulations = 2
215-
num_null_samples = 5
216-
217-
if reference_data is None:
218-
if reference_data == "dict":
219-
reference_data = trainer.configurator(trainer.generative_model(num_reference_simulations))
220-
elif reference_data == "numpy":
221-
reference_data = trainer.configurator(trainer.generative_model(num_reference_simulations))['summary_conditions']
222-
223-
if observed_data_type == "dict":
224-
observed_data = trainer.configurator(trainer.generative_model(num_observed_simulations))
225-
elif observed_data_type == "numpy":
226-
observed_data = trainer.configurator(trainer.generative_model(num_observed_simulations))['summary_conditions']
227-
228-
MMD_sampling_distribution, MMD_observed = trainer.mmd_hypothesis_test(observed_data=observed_data,
229-
reference_data=reference_data,
230-
num_reference_simulations=num_reference_simulations,
231-
num_null_samples=num_null_samples,
232-
bootstrap=bootstrap)
233-
234-
assert MMD_sampling_distribution.shape[0] == num_reference_simulations
235-
assert np.all(MMD_sampling_distribution > 0)

0 commit comments

Comments
 (0)