-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when changing bins in VR #340
Comments
Hi @ekourlit, thanks for reporting this! My guess is that some of the bins are empty after changing the binning, and they will have zero Here is an example workspace for this: {
"channels": [
{
"name": "SR",
"samples": [
{
"data": [10.0, 0.0],
"modifiers": [
{
"data": [1.0, 0.0],
"name": "staterror_SR",
"type": "staterror"
},
{"data": null, "name": "mu", "type": "normfactor"}
],
"name": "Signal"
}
]
}
],
"measurements": [
{
"config": {"parameters": [], "poi": "mu"},
"name": "minimal_example"
}
],
"observations": [{"data": [15, 0], "name": "SR"}],
"version": "1.0.0"
} which will fail at the assertion you point out: assert len(sigmas[sigmas > 0]) == pdfconfig.param_set(mod).n_parameters If this is indeed the explanation for what you observe, then the next release of Two other things that can help:
A post-processing step may be a decent stop-gap solution until the next |
Thanks @alexander-held for the quick reply! That was exactly the problem! I previously checked for zero yields in each sample/bin but the problem was actually the As a temporary workaround I modified the workspace with a post-processing step as you mentioned. I looped over the bins (nominal yields and def zeroless_ws(workspace):
'''
Utility function to look all the bins of the workspace and substitute zeros (nominal and statterror) with 1e-5
this is a temporary fix unlti the next release of cabinetry+pyhf that could handle zero statterror
'''
# loop over regions
for region_idx in range( len(workspace['channels']) ):
region = workspace['channels'][region_idx] #dict
# print("region name %s" % region['name'])
# loop over samples
for sample_idx in range( len(region['samples']) ):
sample = region['samples'][sample_idx] #dict
# print(sample) #dict
# loop over sample data bins and replace zeros
for bin_idx in range( len(sample['data']) ):
counts = sample['data'][bin_idx]
# print(counts)
if counts == 0.0:
print("found an empty bin! \t substituting with 1e-5...")
sample['data'][bin_idx] = 1e-5
staterror_modifier = sample['modifiers'][0] #dict
# double check this is a statterror type
if not staterror_modifier['type'] == 'staterror':
print("another type of modifier found! \t breaking!")
break
# loop over sample modifiers staterror bins and replace zeros
for bin_idx in range( len(staterror_modifier['data']) ):
counts = staterror_modifier['data'][bin_idx]
# print(counts)
if counts == 0.0:
print("found an empty staterror bin! \t substituting with 1e-5...")
staterror_modifier['data'][bin_idx] = 1e-5
# fix workspace, i.e. replace zero bin yields and staterrors with 1e-5
zeroless_ws(ws) |
Thank you for confirming that this was the issue in your setup. Given that the next release of We could also consider adding this workaround to |
I'm opening this issue for an error I face when I change the bins in one of my regions.
I have a multiple region fit setup, where all the regions are single binned, except one which is multi binned. When I change the binning of the multi bin region, I get an
AssertionError
from thispyhf
line. This is not happening with every binning, I have other bin configurations that work fine (even with empty bins): example1, example2.I am using
cabinetry
version 0.4.1 andpyhf
version 0.6.3. I note that the exact above erroneous line do not exist in currentmaster
branch ofpyhf
.The fit configuration can be found here. The steering notebook here. And the error text here.
Any insight will be helpful! Thanks in advance!
The text was updated successfully, but these errors were encountered: