Parsing workspace specifications without POIs #1602
-
#950 introduced the possibility to build models without POIs. There are two ways to use this feature that I am aware of:
It is however not possible to start with a workspace specification that does not include the POI, as the workspace schema requires it. Are there some useful workarounds for this limitation? Workspaces without POIs can for example arise dynamically due to pruning of samples (e.g. the signal sample, cc @Daniel-Noel). Pruned workspaces can then be difficult to use. Would it potentially make sense to allow parsing a workspace while bypassing the schema validation to help with this use case? Instead of bypassing the schema completely, maybe a special handling for the POI could be added when An example to demonstrate things in more detail, using import copy
import pyhf
spec = {
"channels": [
{
"name": "SR",
"samples": [
{
"data": [51.8],
"modifiers": [
{"data": [2.6], "name": "staterror_SR", "type": "staterror"},
{"data": None, "name": "mu", "type": "normfactor"},
],
"name": "signal",
}
],
}
],
"measurements": [
{
"config": {"parameters": [], "poi": "mu"},
"name": "example",
}
],
"observations": [{"data": [52], "name": "SR"}],
"version": "1.0.0",
}
model = pyhf.Workspace(spec).model() # works fine
model = pyhf.Workspace(spec).model(poi_name=None) # works fine
spec_without_poi = copy.deepcopy(spec)
spec_without_poi["measurements"][0]["config"].pop("poi")
# model = pyhf.Workspace(spec_without_poi).model() # does not work
# model = pyhf.Workspace(spec_without_poi).model(poi_name=None) # does not work either
# workaround: extract model specification
model_spec = {"channels": spec_without_poi["channels"]}
model = pyhf.Model(model_spec, poi_name=None) Construction of a model from the original specification works fine. After removal of the POI, the workspace corresponding to the new It is possible to build a model schema and then build the model directly from that, however this approach has a big downside: other measurement config options (for example inits of parameters, or setting parameters to constant, or parameter ranges) cannot be propagated to a model created in this manner. Is there a workaround for this limitation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
See #1638. |
Beta Was this translation helpful? Give feedback.
See #1638.