Open alexander-held opened 3 years ago
I agree we should catch this, but in some ways the user already knows that this call will fail. Since you need to somehow construct aux_data
from scratch so you know the model is constraint-less and calling model.constraint_logpdf(aux_data,pars)
does not make sense.
what would be your preferred behavior?
I am not sure what behavior I would prefer. I think one way a user can construct aux_data
without knowing it will be empty is via slicing
main_data = pyhf.tensorlib.astensor(data[:model.config.nmaindata])
aux_data = pyhf.tensorlib.astensor(data[model.config.nmaindata:])
The least disruptive solution may be to return 0.0
as evaluated constraint term if no term is actually present. I think raising an error is also fine, and maybe more informative. Users who evaluate the terms separately likely already know enough about the model so that neither behavior would be an issue.
Question
Slightly related to #1371, it is not possible to use
Model.constraint_logpdf
for models without constraint terms. This is an edge case, and one might argue that this should not work if no constraint term is present. I would suggest either catching this with an error, or returning 0, unless a different part of the API could be used to get the likelihood contribution per term?Example:
returns
since the pdf built in https://github.com/scikit-hep/pyhf/blob/98bb222d9c45ad13335ab5423d866e3a1508c329/src/pyhf/pdf.py#L658 has only one component.
Relevant Issues and Pull Requests
1371