Skip to content
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

fix up indexing of summed_mask in shapesys, staterror #333

Merged
merged 2 commits into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pyhf/modifiers/shapesys.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ def __init__(self,shapesys_mods,pdfconfig,mega_mods):
zero_mask = summed_mask == 0
# then apply the mask
summed_mask[positive_mask] = inds
summed_mask[zero_mask] = -1
# nb: old code above was
# summed_mask[summed_mask > 0] = inds
# summed_mask[summed_mask == 0] = -1
# This code broke when the `inds` included a '0' because it would replace that value with -1.
summed_mask[zero_mask] = 0
access_rows.append(summed_mask.tolist())
self._factor_access_indices = default_backend.tolist(default_backend.stack(access_rows))
self.finalize(pdfconfig)
Expand Down
8 changes: 6 additions & 2 deletions pyhf/modifiers/staterror.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ def __init__(self,staterr_mods,pdfconfig,mega_mods):
for mask,inds in zip(staterror_mask, self._staterror_indices):
summed_mask = default_backend.sum(mask[:,0,:],axis=0)
assert default_backend.shape(summed_mask[summed_mask > 0]) == default_backend.shape(default_backend.astensor(inds))
summed_mask[summed_mask > 0] = inds
summed_mask[summed_mask == 0] = -1
# make masks of > 0 and == 0
positive_mask = summed_mask > 0
zero_mask = summed_mask == 0
# then apply the mask
summed_mask[positive_mask] = inds
summed_mask[zero_mask] = 0
access_rows.append(summed_mask.tolist())
self._factor_access_indices = default_backend.tolist(default_backend.stack(access_rows))
self.finalize(pdfconfig)
Expand Down