Skip to content

Commit

Permalink
also handle shapesys modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-held committed May 12, 2023
1 parent a34efec commit e7ec331
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/pyhf/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,10 @@ def set_poi(self, name):
raise exceptions.InvalidModel(
f"The parameter of interest '{name:s}' cannot be fit as it is not declared in the model specification."
)
if dict(self.modifiers).get(name, "") == "shapefactor":
# in the case of custom modifiers, the desired POI is in self.parameters but
# not in self.modifiers
if self.param_set(name).n_parameters > 1:
# multi-parameter modifiers are not supported as POIs
raise exceptions.InvalidModel(
f"The parameter '{name:s}' is of type 'shapefactor' and thus cannot be used as parameter of interest."
f"The parameter '{name:s}' contains multiple components and is not currently supported as parameter of interest."
)
s = self.par_slice(name)
assert s.stop - s.start == 1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ def test_shapefactor_as_poi():

with pytest.raises(
pyhf.exceptions.InvalidModel,
match="The parameter 'mu' is of type 'shapefactor' and thus cannot be used as "
"parameter of interest.",
match="The parameter 'mu' contains multiple components and is not currently "
"supported as parameter of interest.",
):
pyhf.Workspace(spec).model()

0 comments on commit e7ec331

Please sign in to comment.