Skip to content

Commit c9eb679

Browse files
committed
update the tests for the typed mixed builder
1 parent b42d9d0 commit c9eb679

2 files changed

Lines changed: 8 additions & 32 deletions

File tree

tests/npe_nle_builder_integration_test.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from sbi.neural_nets.estimators import MixedDensityEstimator
1414
from sbi.neural_nets.estimators.tabpfn_flow import TabPFNFlow
1515
from sbi.neural_nets.net_builders.estimator_configs import (
16-
_MIXED_CONTINUOUS_CONFIGS,
1716
MAFConfig,
1817
MDNConfig,
1918
MixedConfig,
@@ -155,17 +154,6 @@ def test_mixed_rejects_a_continuous_model_it_cannot_build(continuous):
155154
MixedConfig(continuous=continuous)
156155

157156

158-
def test_mixed_continuous_configs_match_the_build_functions():
159-
"""Guard against drift between the allowed set and `mixed_nets`."""
160-
from sbi.neural_nets.net_builders.estimator_configs import _DENSITY_CONFIGS
161-
from sbi.neural_nets.net_builders.mixed_nets import model_builders
162-
163-
assert (
164-
frozenset(_DENSITY_CONFIGS[name] for name in model_builders)
165-
== _MIXED_CONTINUOUS_CONFIGS
166-
)
167-
168-
169157
def test_mixed_requires_explicit_auxiliary_widths_for_per_transform_widths():
170158
"""Fallback widths require the continuous config to hold one integer."""
171159
with pytest.raises(ValueError, match="hidden_features"):
@@ -231,22 +219,15 @@ def test_mixed_default_keeps_the_previous_continuous_net():
231219
The mixed build function overrode the spline tail bound with its own value,
232220
so the default continuous config has to carry that rather than `NSFConfig`'s.
233221
"""
234-
import inspect
235-
236-
from sbi.neural_nets.net_builders.mixed_nets import (
237-
_build_mixed_density_estimator,
238-
)
239-
240-
params = inspect.signature(_build_mixed_density_estimator).parameters
241222
continuous = MixedConfig().continuous
242223

243224
assert isinstance(continuous, NSFConfig)
244-
assert continuous.z_score_input == params["z_score_x"].default
245-
assert continuous.tail_bound == params["tail_bound"].default
246-
assert continuous.hidden_features == params["hidden_features"].default
247-
assert continuous.num_transforms == params["num_transforms"].default
248-
assert continuous.num_bins == params["num_bins"].default
249-
assert MixedConfig().dropout_probability == params["dropout_probability"].default
225+
assert continuous.z_score_input == "independent"
226+
assert continuous.tail_bound == 10.0
227+
assert continuous.hidden_features == 50
228+
assert continuous.num_transforms == 5
229+
assert continuous.num_bins == 10
230+
assert MixedConfig().dropout_probability == 0.0
250231

251232

252233
@pytest.mark.parametrize(

tests/sbiutils_test.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,6 @@ def test_z_scoring_structured(z_x, z_theta, build_fn):
483483
model_x = x
484484

485485
implements_transform = model.startswith("zuko") or model == "mdn"
486-
# `mnle` has no config yet, so it keeps the lenient factory path where
487-
# an unusable setting is forwarded and ignored downstream.
488-
legacy = model == "mnle"
489486

490487
# The factories reject a setting the chosen model does not use, so only
491488
# the ones this model has are passed.
@@ -500,14 +497,12 @@ def test_z_scoring_structured(z_x, z_theta, build_fn):
500497
if model not in ("mdn", "made"):
501498
kwargs["num_transforms"] = 1
502499
# `x_dist` is read only by the unconstrained transform.
503-
if modeled_z == "transform_to_unconstrained" and (
504-
implements_transform or legacy
505-
):
500+
if modeled_z == "transform_to_unconstrained" and implements_transform:
506501
kwargs["x_dist"] = dist
507502

508503
unsupported = (
509504
modeled_z == "transform_to_unconstrained" and not implements_transform
510-
) or (condition_z == "transform_to_unconstrained" and not legacy)
505+
) or condition_z == "transform_to_unconstrained"
511506
if unsupported:
512507
with pytest.raises(ValueError, match="transform_to_unconstrained"):
513508
build_fun = build_fn(**kwargs)

0 commit comments

Comments
 (0)