From 922438e9c474a9d88859f6f435b5b24cf9407945 Mon Sep 17 00:00:00 2001 From: Alexander Held Date: Thu, 11 May 2023 11:35:19 -0400 Subject: [PATCH] handle custom modifiers --- src/pyhf/pdf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pyhf/pdf.py b/src/pyhf/pdf.py index 50a94bfdbc..20123d81bb 100644 --- a/src/pyhf/pdf.py +++ b/src/pyhf/pdf.py @@ -464,7 +464,9 @@ 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)[name] == "shapefactor": + 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 raise exceptions.InvalidModel( f"The parameter '{name:s}' is of type 'shapefactor' and thus cannot be used as parameter of interest." )