@@ -16,7 +16,8 @@ def test_print_results(caplog):
16
16
bestfit = np .asarray ([1.0 , 2.0 ])
17
17
uncertainty = np .asarray ([0.1 , 0.3 ])
18
18
labels = ["param_A" , "param_B" ]
19
- fit_results = fit .FitResults (bestfit , uncertainty , labels , np .empty (0 ), 0.0 )
19
+ types = ["normsys" , "shapesys" ]
20
+ fit_results = fit .FitResults (bestfit , uncertainty , labels , types , np .empty (0 ), 0.0 )
20
21
21
22
fit .print_results (fit_results )
22
23
assert "param_A = 1.0000 +/- 0.1000" in [rec .message for rec in caplog .records ]
@@ -143,13 +144,13 @@ def test__fit_model_custom(mock_minos, example_spec, example_spec_multibin):
143
144
@mock .patch (
144
145
"cabinetry.fit._fit_model_custom" ,
145
146
return_value = fit .FitResults (
146
- np .asarray ([1.2 ]), np .asarray ([0.2 ]), ["par" ], np .empty (0 ), 2.0
147
+ np .asarray ([1.2 ]), np .asarray ([0.2 ]), ["par" ], [ "normsys" ], np .empty (0 ), 2.0
147
148
),
148
149
)
149
150
@mock .patch (
150
151
"cabinetry.fit._fit_model_pyhf" ,
151
152
return_value = fit .FitResults (
152
- np .asarray ([1.1 ]), np .asarray ([0.2 ]), ["par" ], np .empty (0 ), 2.0
153
+ np .asarray ([1.1 ]), np .asarray ([0.2 ]), ["par" ], [ "normsys" ], np .empty (0 ), 2.0
153
154
),
154
155
)
155
156
def test__fit_model (mock_pyhf , mock_custom , example_spec ):
@@ -295,7 +296,7 @@ def test__goodness_of_fit(
295
296
@mock .patch (
296
297
"cabinetry.fit._fit_model" ,
297
298
return_value = fit .FitResults (
298
- np .asarray ([1.0 ]), np .asarray ([0.1 ]), ["par" ], np .empty (0 ), 2.0
299
+ np .asarray ([1.0 ]), np .asarray ([0.1 ]), ["par" ], [ "normsys" ], np .empty (0 ), 2.0
299
300
),
300
301
)
301
302
def test_fit (mock_fit , mock_print , mock_gof ):
@@ -382,33 +383,78 @@ def test_fit(mock_fit, mock_print, mock_gof):
382
383
"cabinetry.fit._fit_model" ,
383
384
side_effect = [
384
385
fit .FitResults (
385
- np .asarray ([0.9 , 1.3 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
386
+ np .asarray ([0.9 , 1.3 ]),
387
+ np .asarray ([0.1 , 0.1 ]),
388
+ ["a" , "b" ],
389
+ ["normsys" , "normsys" ],
390
+ np .empty (0 ),
391
+ 0.0 ,
386
392
),
387
393
fit .FitResults (
388
- np .asarray ([0.9 , 0.7 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
394
+ np .asarray ([0.9 , 0.7 ]),
395
+ np .asarray ([0.1 , 0.1 ]),
396
+ ["a" , "b" ],
397
+ ["normsys" , "normsys" ],
398
+ np .empty (0 ),
399
+ 0.0 ,
389
400
),
390
401
fit .FitResults (
391
- np .asarray ([0.9 , 1.2 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
402
+ np .asarray ([0.9 , 1.2 ]),
403
+ np .asarray ([0.1 , 0.1 ]),
404
+ ["a" , "b" ],
405
+ ["normsys" , "normsys" ],
406
+ np .empty (0 ),
407
+ 0.0 ,
392
408
),
393
409
fit .FitResults (
394
- np .asarray ([0.9 , 0.8 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
410
+ np .asarray ([0.9 , 0.8 ]),
411
+ np .asarray ([0.1 , 0.1 ]),
412
+ ["a" , "b" ],
413
+ ["normsys" , "normsys" ],
414
+ np .empty (0 ),
415
+ 0.0 ,
395
416
),
396
417
# for second ranking call with fixed parameter
397
418
fit .FitResults (
398
- np .asarray ([0.9 , 1.2 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
419
+ np .asarray ([0.9 , 1.2 ]),
420
+ np .asarray ([0.1 , 0.1 ]),
421
+ ["a" , "b" ],
422
+ ["normsys" , "normsys" ],
423
+ np .empty (0 ),
424
+ 0.0 ,
399
425
),
400
426
fit .FitResults (
401
- np .asarray ([0.9 , 0.8 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
427
+ np .asarray ([0.9 , 0.8 ]),
428
+ np .asarray ([0.1 , 0.1 ]),
429
+ ["a" , "b" ],
430
+ ["normsys" , "normsys" ],
431
+ np .empty (0 ),
432
+ 0.0 ,
402
433
),
403
434
# for third ranking call without reference results
404
435
fit .FitResults (
405
- np .asarray ([0.9 , 1.0 ]), np .asarray ([0.3 , 0.3 ]), ["a" , "b" ], np .empty (0 ), 0.0
436
+ np .asarray ([0.9 , 1.0 ]),
437
+ np .asarray ([0.3 , 0.3 ]),
438
+ ["a" , "b" ],
439
+ ["normsys" , "normsys" ],
440
+ np .empty (0 ),
441
+ 0.0 ,
406
442
),
407
443
fit .FitResults (
408
- np .asarray ([0.9 , 1.3 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
444
+ np .asarray ([0.9 , 1.3 ]),
445
+ np .asarray ([0.1 , 0.1 ]),
446
+ ["a" , "b" ],
447
+ ["normsys" , "normsys" ],
448
+ np .empty (0 ),
449
+ 0.0 ,
409
450
),
410
451
fit .FitResults (
411
- np .asarray ([0.9 , 0.7 ]), np .asarray ([0.1 , 0.1 ]), ["a" , "b" ], np .empty (0 ), 0.0
452
+ np .asarray ([0.9 , 0.7 ]),
453
+ np .asarray ([0.1 , 0.1 ]),
454
+ ["a" , "b" ],
455
+ ["normsys" , "normsys" ],
456
+ np .empty (0 ),
457
+ 0.0 ,
412
458
),
413
459
],
414
460
)
@@ -417,7 +463,8 @@ def test_ranking(mock_fit, example_spec):
417
463
bestfit = np .asarray ([0.9 , 1.0 ])
418
464
uncertainty = np .asarray ([0.02 , 0.1 ])
419
465
labels = ["staterror" , "mu" ]
420
- fit_results = fit .FitResults (bestfit , uncertainty , labels , np .empty (0 ), 0.0 )
466
+ types = ["staterror" , "normfactor" ]
467
+ fit_results = fit .FitResults (bestfit , uncertainty , labels , types , np .empty (0 ), 0.0 )
421
468
model , data = model_utils .model_and_data (example_spec )
422
469
ranking_results = fit .ranking (model , data , fit_results = fit_results )
423
470
@@ -500,16 +547,16 @@ def test_ranking(mock_fit, example_spec):
500
547
"cabinetry.fit._fit_model" ,
501
548
side_effect = [
502
549
fit .FitResults (
503
- np .asarray ([0.9 , 1.3 ]), np .asarray ([0.1 , 0.1 ]), [], np .empty (0 ), 8.0
550
+ np .asarray ([0.9 , 1.3 ]), np .asarray ([0.1 , 0.1 ]), [], [], np .empty (0 ), 8.0
504
551
)
505
552
] # nominal fit
506
553
+ [
507
- fit .FitResults (np .empty (0 ), np .empty (0 ), [], np .empty (0 ), abs (i ) + 8 )
554
+ fit .FitResults (np .empty (0 ), np .empty (0 ), [], [], np .empty (0 ), abs (i ) + 8 )
508
555
for i in np .linspace (- 5 , 5 , 11 )
509
556
] # fits in scan
510
557
+ [
511
558
fit .FitResults (
512
- np .asarray ([0.9 , 1.3 ]), np .asarray ([0.1 , 0.1 ]), [], np .empty (0 ), 2.0
559
+ np .asarray ([0.9 , 1.3 ]), np .asarray ([0.1 , 0.1 ]), [], [], np .empty (0 ), 2.0
513
560
)
514
561
]
515
562
* 6 , # fits for custom parameter range
0 commit comments