diff --git a/src/pyhf/pdf.py b/src/pyhf/pdf.py index 20123d81bb..aaf69a5c87 100644 --- a/src/pyhf/pdf.py +++ b/src/pyhf/pdf.py @@ -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 diff --git a/tests/test_pdf.py b/tests/test_pdf.py index 75b7957757..d0f1ac0b81 100644 --- a/tests/test_pdf.py +++ b/tests/test_pdf.py @@ -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()