1717
1818
1919pytestmark = pytest .mark .filterwarnings ("ignore::FutureWarning" )
20+ requires_nss = pytest .mark .skipif (
21+ not nss_search_module ._HAS_NSS ,
22+ reason = "requires optional `nss` extra" ,
23+ )
2024
2125
26+ @requires_nss
2227def test__explicit_params ():
2328 search = af .NSS (
2429 n_live = 500 ,
@@ -70,6 +75,7 @@ def test__chunked_update_strategy_factory():
7075 ]
7176
7277
78+ @requires_nss
7379def test__chunked_nss_algorithm_factory ():
7480 """``build_chunked_nss_algorithm`` returns a ``blackjax.SamplingAlgorithm``-
7581 shape NamedTuple with ``init`` and ``step`` attributes. This is what
@@ -106,12 +112,14 @@ def test__chunked_nss_algorithm_factory():
106112 assert isinstance (algo_unchunked , blackjax .SamplingAlgorithm )
107113
108114
115+ @requires_nss
109116def test__identifier_fields ():
110117 search = af .NSS ()
111118 for field in ("n_live" , "num_mcmc_steps" , "num_delete" , "termination" , "seed" ):
112119 assert field in search .__identifier_fields__
113120
114121
122+ @requires_nss
115123def test__test_mode_loosens_termination ():
116124 search = af .NSS (termination = - 3.0 )
117125 search .apply_test_mode ()
@@ -124,6 +132,7 @@ def test__init_raises_when_nss_unavailable(monkeypatch):
124132 af .NSS ()
125133
126134
135+ @requires_nss
127136def test__init_warns_when_number_of_cores_gt_one (caplog ):
128137 with caplog .at_level ("WARNING" ):
129138 af .NSS (number_of_cores = 4 )
@@ -157,6 +166,7 @@ def _make_synthetic_internal(n_live=20, ndim=2, seed=0):
157166 )
158167
159168
169+ @requires_nss
160170def test__samples_info_from_synthetic_internal ():
161171 search = af .NSS ()
162172 internal = _make_synthetic_internal ()
@@ -178,6 +188,7 @@ def test__samples_info_from_synthetic_internal():
178188 assert info ["sampling_time" ] == pytest .approx (10.0 , abs = 1e-12 )
179189
180190
191+ @requires_nss
181192def test__samples_via_internal_from_returns_nssamples ():
182193 model = af .Model (af .m .MockClassx2 )
183194 model .one = af .UniformPrior (lower_limit = - 3.0 , upper_limit = 3.0 )
@@ -201,6 +212,7 @@ def test__samples_via_internal_from_returns_nssamples():
201212 )
202213
203214
215+ @requires_nss
204216def test__samples_weight_normalisation_handles_zero_total ():
205217 """When every log_weight is -inf (e.g. catastrophic underflow) we should
206218 not divide by zero. The implementation clamps via max-subtraction so this
@@ -222,6 +234,7 @@ def test__samples_weight_normalisation_handles_zero_total():
222234 assert np .allclose (weights , 1.0 / 10 , atol = 1e-12 )
223235
224236
237+ @requires_nss
225238def test__nssamples_log_evidence_error_property ():
226239 model = af .Model (af .m .MockClassx2 )
227240 model .one = af .UniformPrior (lower_limit = - 3.0 , upper_limit = 3.0 )
0 commit comments