Skip to content

Commit 0c8c0c4

Browse files
test: Verify NLL values and Minuit parameter uncertainties (#1197)
* Add a test for the NLL value returned by minimization * Explicitly specify the fixed_vals kwarg for function calls passing in fixed parameter values
1 parent fbe0252 commit 0c8c0c4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_optim.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def test_optim(backend, source, spec, mu):
351351
pdf,
352352
init_pars,
353353
par_bounds,
354-
[(pdf.config.poi_index, mu)],
354+
fixed_vals=[(pdf.config.poi_index, mu)],
355355
)
356356
assert pyhf.tensorlib.tolist(result)
357357

@@ -375,11 +375,12 @@ def test_optim_with_value(backend, source, spec, mu):
375375
pdf,
376376
init_pars,
377377
par_bounds,
378-
[(pdf.config.poi_index, mu)],
378+
fixed_vals=[(pdf.config.poi_index, mu)],
379379
return_fitted_val=True,
380380
)
381381
assert pyhf.tensorlib.tolist(result)
382382
assert pyhf.tensorlib.shape(fitted_val) == ()
383+
assert pytest.approx(17.52954975, rel=1e-5) == fitted_val
383384

384385

385386
@pytest.mark.parametrize('mu', [1.0], ids=['mu=1'])
@@ -402,11 +403,11 @@ def test_optim_uncerts(backend, source, spec, mu):
402403
pdf,
403404
init_pars,
404405
par_bounds,
405-
[(pdf.config.poi_index, mu)],
406+
fixed_vals=[(pdf.config.poi_index, mu)],
406407
return_uncertainties=True,
407408
)
408409
assert result.shape[1] == 2
409-
assert pyhf.tensorlib.tolist(result)
410+
assert pytest.approx([0.0, 0.26418431]) == pyhf.tensorlib.tolist(result[:, 1])
410411

411412

412413
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)