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
2 changes: 1 addition & 1 deletion bayesflow/approximators/continuous_approximator.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def _sample(
)
batch_shape = keras.ops.shape(inference_conditions)[:-1]
else:
batch_shape = keras.ops.shape(inference_conditions)[1:-1]
batch_shape = (num_samples,)

return self.inference_network.sample(
batch_shape, conditions=inference_conditions, **filter_kwargs(kwargs, self.inference_network.sample)
Expand Down
17 changes: 16 additions & 1 deletion tests/test_approximators/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def point_inference_network_with_multiple_parametric_scores():
def point_approximator_with_single_parametric_score(adapter, point_inference_network, summary_network):
from bayesflow import PointApproximator

if "-> 'inference_conditions'" not in str(adapter) and "-> 'summary_conditions'" not in str(adapter):
pytest.skip("point approximator does not support unconditional estimation")

return PointApproximator(
adapter=adapter,
inference_network=point_inference_network,
Expand All @@ -81,6 +84,9 @@ def point_approximator_with_multiple_parametric_scores(
):
from bayesflow import PointApproximator

if "-> 'inference_conditions'" not in str(adapter) and "-> 'summary_conditions'" not in str(adapter):
pytest.skip("point approximator does not support unconditional estimation")

return PointApproximator(
adapter=adapter,
inference_network=point_inference_network_with_multiple_parametric_scores,
Expand Down Expand Up @@ -128,7 +134,16 @@ def adapter_with_sample_weight():
)


@pytest.fixture(params=["adapter_without_sample_weight", "adapter_with_sample_weight"])
@pytest.fixture()
def adapter_unconditional():
from bayesflow import ContinuousApproximator

return ContinuousApproximator.build_adapter(
inference_variables=["mean", "std"],
)


@pytest.fixture(params=["adapter_unconditional", "adapter_without_sample_weight", "adapter_with_sample_weight"])
def adapter(request):
return request.getfixturevalue(request.param)

Expand Down