Skip to content

Commit b23aceb

Browse files
committed
Update config
1 parent 5bb7b1e commit b23aceb

File tree

11 files changed

+18
-14
lines changed

11 files changed

+18
-14
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest, windows-latest]
13-
python-version: ['3.8']
13+
python-version: ['3.9']
1414

1515
steps:
1616
- uses: actions/checkout@v2

bayesflow/amortizers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ def sample(self, input_dict, n_samples, to_numpy=True, **kwargs):
513513
# Obtain random draws from the surrogate likelihood given conditioning variables
514514
lik_samples = self.surrogate_net.inverse(z_samples, conditions, training=False, **kwargs)
515515

516+
# Only return 2D array, if first dimensions is 1
517+
if lik_samples.shape[0] == 1:
518+
lik_samples = lik_samples[0]
519+
516520
if to_numpy:
517521
return lik_samples.numpy()
518522
return lik_samples

environment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name: bf
44
dependencies:
5-
- python==3.8
5+
- python==3.9
66
- pip
77
- pip:
88
- -r requirements.txt

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
h5py==3.5
22
numba===0.55
3-
numpy==1.19
3+
numpy==1.21
44
pandas==1.4
55
scikit-learn==1.1
66
scipy==1.9
@@ -13,4 +13,4 @@ matplotlib==3.5
1313
m2r2==0.3
1414
ipykernel==6.7
1515
nbsphinx==0.8
16-
ipywidgets==7.6.5
16+
ipywidgets==7.6.5

setup.cfg

Lines changed: 1 addition & 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.8
33+
python_requires = >=3.9
3434
packages = find:
3535
install_requires =
3636
h5py >= 3.6

tests/test_amortizers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_amortized_posterior(cond_shape, summary_loss, soft):
121121
# Log posterior and lpdf should be the same, unless using softflow
122122
# which will introduce some noise in the untrained version
123123
if not soft:
124-
assert np.allclose(log_post, lpdf, atol=1e-6)
124+
assert np.allclose(log_post, lpdf, atol=1e-5)
125125

126126
# Test shape of samples
127127
if batch_size == 1:
@@ -223,7 +223,7 @@ def test_amortized_likelihood(inp_shape, soft):
223223
# Log posterior and lpdf should be the same, unless using softflow
224224
# which will introduce some noise in the untrained version
225225
if not soft:
226-
assert np.allclose(log_lik, lpdf, atol=1e-6)
226+
assert np.allclose(log_lik, lpdf, atol=1e-5)
227227

228228
# Test shape of samples
229229
if batch_size == 1:

tests/test_coupling_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_coupling_layer(condition, spec_norm, use_perm, use_act_norm, input_shap
9090
else:
9191
assert network.act_norm is None
9292
# Test invertibility
93-
assert np.allclose(inp, inp_rec, atol=1e-6)
93+
assert np.allclose(inp, inp_rec, atol=1e-5)
9494
# Test shapes (bijectivity)
9595
assert z.shape == inp.shape
9696
if input_shape == '2d':

tests/test_helper_networks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_invariant_module(n_dense_s1, n_dense_s2, output_dim):
138138
out_perm = inv_module(x_perm).numpy()
139139

140140
# Assert outputs equal
141-
assert np.allclose(out, out_perm, atol=1e-6)
141+
assert np.allclose(out, out_perm, atol=1e-5)
142142
# Assert shape 2d
143143
assert len(out.shape) == 2 and len(out_perm.shape) == 2
144144
# Assert first and last dimension equals output dimension
@@ -172,7 +172,7 @@ def test_equivariant_module(n_dense_s3, output_dim):
172172
out_perm = equiv_module(x_perm).numpy()
173173

174174
# Assert outputs equal
175-
assert np.allclose(out[:, perm, :], out_perm, atol=1e-6)
175+
assert np.allclose(out[:, perm, :], out_perm, atol=1e-5)
176176
# Assert shape 3d
177177
assert len(out.shape) == 3 and len(out_perm.shape) == 3
178178
# Assert first and last dimension equals output dimension

tests/test_inference_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_invertible_network(input_shape, condition, use_act_norm, use_soft_flow,
9797
assert network.soft_flow is False
9898
# Test invertibility (in case no soft flow)
9999
if not use_soft_flow:
100-
assert np.allclose(inp, inp_rec, atol=1e-6)
100+
assert np.allclose(inp, inp_rec, atol=1e-5)
101101
# Test shapes (bijectivity)
102102
assert z.shape == inp.shape
103103
assert z.shape[-1] == input_dim

tests/test_summary_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_invariant_network(num_equiv, summary_dim):
6565
# Assert numebr of equivariant layers correct
6666
assert len(inv_net.equiv_layers.layers) == num_equiv
6767
# Assert outputs equal
68-
assert np.allclose(out, out_perm, atol=1e-6)
68+
assert np.allclose(out, out_perm, atol=1e-5)
6969
# Assert shape 2d
7070
assert len(out.shape) == 2 and len(out_perm.shape) == 2
7171
# Assert batch and last dimension equals output dimension

0 commit comments

Comments
 (0)