Is there/could there be an "official" Model._modifications(pars)
implementation?
#1414
-
This sounds very useful to me, e.g. with a use case like in get_mc_counts in this example. If generalized, this would make it possible to do generic pre-fit and post-fit plots of distributions, purely from the data in a workspace or model specification. The only data necessary to inject from the outside would be info about the bin edges. However, when I tried using >>> import pyhf
>>> assert pyhf.__version__ == '0.6.1'
>>> pdf = pyhf.simplemodels.hepdata_like(
... signal_data=[12.0, 11.0],
... bkg_data=[50.0, 52.0],
... bkg_uncerts=[3.0, 7.0],
... )
>>> pdf._modifications(pdf.config.suggested_init())
TypeError Traceback (most recent call last)
...
TypeError: only integer scalar arrays can be converted to a scalar index
>>> # it really is due to shapesys.py:168
>>> pdf.spec['channels'][0]['samples'][1]['modifiers'].pop()
{'name': 'uncorr_bkguncrt', 'type': 'shapesys', 'data': [3.0, 7.0]}
>>> pdf = pyhf.Model(pdf.spec)
>>> pdf._modifications(pdf.config.suggested_init())
([],
[array([[[[1., 1.]],
[[1., 1.]]]])]) So the question is: Is there already a better way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Hi, if you are looking for pre- and post-fit distributions, the Lines 479 to 505 in 671ed56 You might also be interested in |
Beta Was this translation helpful? Give feedback.
Hi, if you are looking for pre- and post-fit distributions, the
Model.main_model.expected_data
API is suitable (I think this is not documented in the API since_MainModel
is not public?):pyhf/src/pyhf/pdf.py
Lines 479 to 505 in 671ed56