pyhs3.hifa_modifier_settings

pyhs3.hifa_modifier_settings(ws, *, likelihood=None)[source]

pyhf’s modifier_settings for the workspace to_hifa() converts.

pyhf’s JSON holds no interpolation codes; pass these to pyhf.Workspace.model(modifier_settings=...) so pyhf interpolates as pyhs3 does. Both modifier types are always given, with pyhs3’s (and ROOT’s) defaults code4 for normsys and code4p for histosys when no modifier of that type is converted: pyhf falls back to other codes for a type modifier_settings leaves out.

likelihood selects the channels as it does for to_hifa(), so channels the conversion leaves out cannot make the codes ambiguous.

A histosys with code2 logs a warning: pyhs3’s code2 differs from pyhf’s for |alpha| > 1 (pyhf#2729).

Parameters:
Return type:

dict[str, dict[str, str]]

Returns:

{"normsys": {"interpcode": ...}, "histosys": {"interpcode": ...}}.

Raises:

ValueError – For one modifier type using more than one code, and whatever to_hifa() raises while selecting the likelihood and its channels.

Examples

>>> import pyhs3
>>> spec = {
...     "channels": [
...         {
...             "name": "SR",
...             "samples": [
...                 {
...                     "name": "background",
...                     "data": [50.0],
...                     "modifiers": [
...                         {
...                             "name": "bkg_norm",
...                             "type": "normsys",
...                             "data": {"hi": 1.1, "lo": 0.9},
...                         }
...                     ],
...                 }
...             ],
...         }
...     ],
...     "observations": [{"name": "SR", "data": [52.0]}],
...     "measurements": [
...         {"name": "meas", "config": {"poi": "bkg_norm", "parameters": []}}
...     ],
...     "version": "1.0.0",
... }
>>> ws = pyhs3.from_hifa(
...     spec, modifier_settings={"normsys": {"interpcode": "code1"}}
... )
>>> pyhs3.hifa_modifier_settings(ws)
{'normsys': {'interpcode': 'code1'}, 'histosys': {'interpcode': 'code4p'}}