Splitting data for a model into main and aux data
See original GitHub issueQuestion
Is there a recommended way to split data (main + aux) into the “main” part (yields per bin) and auxiliary?
Given a model: pyhf.pdf.Model and data: List[float] (e.g. from workspace.data(model)), the following works as long as there is at least a single aux parameter (I do not remember from where I picked this up, but I believe it was a suggestion):
main_data, aux_data = model.fullpdf_tv.split(pyhf.tensorlib.astensor(data))
With no aux parameters, this fails since a list of length 1 is returned. I could instead split like this
main_data = data[:model.config.nmaindata]
aux_data = data[model.config.nmaindata:]
which would return [] when model.config.nauxdata is zero.
Do you see any possible issue with this second approach? Looking at https://github.com/scikit-hep/pyhf/blob/f380fddf331c89030384e7949c76099e9277693a/src/pyhf/probability.py#L281-L283 I doubt that changing the .split() behavior would make sense for the API.
Relevant Issues and Pull Requests
none I am aware of
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)

Top Related StackOverflow Question
ok, i’ll close this then for now, but feel free to reopen if it becomes annoying (I do think this will be rare in real-life scenarios)
This is fine, happy to use an approach like this. If this kind of split is commonly needed it might be useful to have something in the API for it, but I suspect it is a rare thing to use.
model.fullpdf_tv.split(data)indeed always works, just need to handle the length-1 case accordingly.