diff --git a/src/pyhf/pdf.py b/src/pyhf/pdf.py index f6cf54b362..3b55f2369a 100644 --- a/src/pyhf/pdf.py +++ b/src/pyhf/pdf.py @@ -464,10 +464,13 @@ 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." ) - s = self.par_slice(name) - assert s.stop - s.start == 1 + if self.param_set(name).n_parameters > 1: + # multi-parameter modifiers are not supported as POIs + raise exceptions.InvalidModel( + f"The parameter '{name:s}' contains multiple components and is not currently supported as parameter of interest." + ) self._poi_name = name - self._poi_index = s.start + self._poi_index = self.par_slice(name).start def _create_and_register_paramsets(self, required_paramsets): next_index = 0 diff --git a/tests/test_pdf.py b/tests/test_pdf.py index 045575d725..e680dad3f6 100644 --- a/tests/test_pdf.py +++ b/tests/test_pdf.py @@ -1329,3 +1329,33 @@ def test_is_shared_paramset_shapesys_same_sample_same_channel(): with pytest.raises(pyhf.exceptions.InvalidModel): pyhf.Workspace(spec).model() + + +def test_multi_component_poi(): + spec = { + "channels": [ + { + "name": "SR", + "samples": [ + { + "data": [5.0, 10.0], + "modifiers": [ + {"data": None, "name": "mu", "type": "shapefactor"} + ], + "name": "Signal", + } + ], + } + ], + "measurements": [ + {"config": {"parameters": [], "poi": "mu"}, "name": "example"} + ], + "observations": [{"data": [5.0, 10.0], "name": "SR"}], + "version": "1.0.0", + } + + with pytest.raises( + pyhf.exceptions.InvalidModel, + match="The parameter 'mu' contains multiple components and is not currently supported as parameter of interest.", + ): + pyhf.Workspace(spec).model()