Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up to Series 1.1.5 update #143

Merged
merged 29 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0873ba9
update tutorial notebook 1
rusty-electron Feb 5, 2024
ccfd11a
Merge pull request #120 from rusty-electron/master
stefanradev93 Feb 6, 2024
fd9b13b
manual fix for toc anchor links
rusty-electron Feb 13, 2024
8388d03
update minor text details
rusty-electron Feb 13, 2024
fe63666
Minimal Fix for Broken Tests (#130)
LarsKue Feb 20, 2024
85fee39
Drop Support for Python 3.9, Add Support for Python 3.11 (#132)
LarsKue Feb 20, 2024
6c68a18
Parallelize Tests
LarsKue Feb 20, 2024
06ee85a
Parallelize Tests
LarsKue Feb 20, 2024
801e56f
Merge remote-tracking branch 'origin/Development' into Development
LarsKue Feb 20, 2024
6db815a
add (short) note about latent vectors
rusty-electron Feb 21, 2024
d477cd4
Merge branch 'stefanradev93:Development' into Development
rusty-electron Feb 21, 2024
225a817
Merge pull request #136 from rusty-electron/Development
stefanradev93 Feb 21, 2024
674ee68
make sure that plots work with only one parameter
Kucharssim Feb 21, 2024
512046c
Merge pull request #137 from Kucharssim/oneParameterPlot
stefanradev93 Feb 27, 2024
eb35a14
Include shared context in MultiSimulationDataset for offline training
elseml Feb 27, 2024
9a5b125
Merge remote-tracking branch 'upstream/Development' into Development
elseml Feb 29, 2024
56a8dd5
Fix last epoch validation loss not saving
elseml Mar 1, 2024
3b196c6
Merge pull request #139 from elseml/Development
stefanradev93 Mar 1, 2024
7009aeb
fix: README - minimal example
vpratz Mar 5, 2024
ccb4b94
Merge pull request #141 from vpratz/Development
stefanradev93 Mar 5, 2024
162a616
update TOCs of example notebooks
rusty-electron Mar 6, 2024
4eb185c
Merge pull request #142 from rusty-electron/Development
stefanradev93 Mar 7, 2024
18d519a
Cheap fix for ts transformer test fail
stefanradev93 Mar 7, 2024
35a2b27
Update support and references
stefanradev93 Mar 7, 2024
4eb0f75
Add changes for 1.1.5 series
stefanradev93 Mar 7, 2024
066b958
Small uppercase change to journal names
stefanradev93 Mar 7, 2024
c4ccad8
Drop support for legacy SingleModelAmortizer [skip ci]
stefanradev93 Mar 7, 2024
0b866a9
Add AmortizedPointEstimator
stefanradev93 Mar 7, 2024
6508273
Add new ConfigurableMLP
stefanradev93 Mar 7, 2024
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 .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# From https://github.com/eeholmes/readthedoc-test/blob/main/.github/workflows/docs_pages.yml
name: docs

# execute this workflow automatically when a we push to master
# execute this workflow automatically when we push to master
on:
push:
branches:
Expand All @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
cache: "pip"

- name: Install dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: python3 -m pip install --upgrade build && python3 -m build
- run: python3 -m pip install -U build && python3 -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on:
pull_request:
push:
branches:
branches:
- master
- Development

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
python -m ensurepip
python -m pip install -U pip setuptools wheel
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
2 changes: 1 addition & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Full Installation Instructions
Requirements
------------

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

Expand Down
10 changes: 0 additions & 10 deletions environment.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ no_implicit_reexport = true

[tool.black]
line-length = 120
target-version = ["py39", "py310"]
target-version = ["py310", "py311"]

[tool.isort]
profile = "black"
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
flake8>=6.1.0
tox>=4.10.0
pytest>=7.2.0
pytest-xdist>=3.5.0
pytest-cov>=4.1.0
myp>=1.5.1
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ keywords =
model comparison

[options]
python_requires = >=3.9
python_requires = >=3.10
packages = find:
install_requires =
h5py >= 3.7
Expand All @@ -51,6 +51,7 @@ testing =
flake8 >= 3.9
tox >= 3.24
pytest >= 6.0
pytest-xdist >= 2.4.0
pytest-cov >= 2.10.0
mypy >= 0.910
docs =
Expand Down
5 changes: 2 additions & 3 deletions tests/test_sensitivity.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from copy import deepcopy
from functools import partial
from unittest.mock import MagicMock, Mock

import numpy as np
import pytest
import tensorflow as tf

from copy import deepcopy

from bayesflow import computational_utilities, sensitivity, simulation
from tests.test_trainers import _create_training_setup, _prior, _simulator

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


class TestMisspecificationExperiment:
def setup(self):
def setup_method(self):
self.trainer = _create_training_setup(mode="posterior")

# Mock the approximate posterior sampling of the amortizer, return np.ones of shape (n_sim, n_samples)
Expand Down
35 changes: 2 additions & 33 deletions tests/test_trainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def _create_training_setup(mode):
trainer = Trainer(generative_model=model, amortizer=amortizer)
return trainer


class TestTrainer:
def setup(self):
def setup_method(self):
trainer_posterior = _create_training_setup("posterior")
trainer_likelihood = _create_training_setup("likelihood")
trainer_joint = _create_training_setup("joint")
Expand Down Expand Up @@ -111,7 +112,6 @@ def test_train_online(self, mode, reuse_optimizer, validation_sims):
assert type(h["train_losses"]) is DataFrame
assert type(h["val_losses"]) is DataFrame


@pytest.mark.parametrize("mode", ["posterior", "joint"])
@pytest.mark.parametrize("reuse_optimizer", [True, False])
@pytest.mark.parametrize("validation_sims", [20, None])
Expand Down Expand Up @@ -202,34 +202,3 @@ def test_train_rounds(self, mode, reuse_optimizer, validation_sims):
assert type(h) is dict
assert type(h["train_losses"]) is DataFrame
assert type(h["val_losses"]) is DataFrame

@pytest.mark.parametrize("reference_data", [None, "dict", "numpy"])
@pytest.mark.parametrize("observed_data_type", ["dict", "numpy"])
@pytest.mark.parametrize("bootstrap", [True, False])
def mmd_hypothesis_test_no_reference(self, reference_data, observed_data_type, bootstrap):
trainer = self.trainers["posterior"]
_ = trainer.train_online(epochs=1, iterations_per_epoch=1, batch_size=4)

num_reference_simulations = 10
num_observed_simulations = 2
num_null_samples = 5

if reference_data is None:
if reference_data == "dict":
reference_data = trainer.configurator(trainer.generative_model(num_reference_simulations))
elif reference_data == "numpy":
reference_data = trainer.configurator(trainer.generative_model(num_reference_simulations))['summary_conditions']

if observed_data_type == "dict":
observed_data = trainer.configurator(trainer.generative_model(num_observed_simulations))
elif observed_data_type == "numpy":
observed_data = trainer.configurator(trainer.generative_model(num_observed_simulations))['summary_conditions']

MMD_sampling_distribution, MMD_observed = trainer.mmd_hypothesis_test(observed_data=observed_data,
reference_data=reference_data,
num_reference_simulations=num_reference_simulations,
num_null_samples=num_null_samples,
bootstrap=bootstrap)

assert MMD_sampling_distribution.shape[0] == num_reference_simulations
assert np.all(MMD_sampling_distribution > 0)
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ envlist =

[gh-actions]
python =
3.9: base, flake8
3.10: base, flake8

[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
commands =
pytest --basetemp={envtmpdir}
pytest -n auto --basetemp={envtmpdir}

[testenv:flake8]
basepython = python3.9
basepython = python3.10
deps = flake8
commands = flake8 bayesflow tests

[testenv:base]
extras = test
commands =
pytest tests
pytest tests -n auto

[testenv:docs]
extras =
Expand Down
Loading