-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: Raise exception if bin-wise modifier data length doesn't match sample data #1708
feat: Raise exception if bin-wise modifier data length doesn't match sample data #1708
Conversation
I still need to add tests, but @kratsg and @lukasheinrich if you have early feedback on changes they're welcome — I haven't touched the modifiers in a long time. |
Codecov Report
@@ Coverage Diff @@
## master #1708 +/- ##
=======================================
Coverage 98.11% 98.12%
=======================================
Files 64 64
Lines 4249 4267 +18
Branches 590 593 +3
=======================================
+ Hits 4169 4187 +18
Misses 46 46
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
With the spec that @kratsg gave as an example in Issue #1216 as $ pyhf inspect issue_1216.json
Traceback (most recent call last):
File "/home/feickert/.pyenv/versions/pyhf-dev-CPU/bin/pyhf", line 33, in <module>
sys.exit(load_entry_point('pyhf', 'console_scripts', 'pyhf')())
File "/home/feickert/.pyenv/versions/3.9.6/envs/pyhf-dev-CPU/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/home/feickert/.pyenv/versions/3.9.6/envs/pyhf-dev-CPU/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/feickert/.pyenv/versions/3.9.6/envs/pyhf-dev-CPU/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/feickert/.pyenv/versions/3.9.6/envs/pyhf-dev-CPU/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/feickert/.pyenv/versions/3.9.6/envs/pyhf-dev-CPU/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/feickert/Code/GitHub/pyhf/src/pyhf/cli/spec.py", line 82, in inspect
model = ws.model()
File "/home/feickert/Code/GitHub/pyhf/src/pyhf/workspace.py", line 425, in model
return Model(modelspec, **config_kwargs)
File "/home/feickert/Code/GitHub/pyhf/src/pyhf/pdf.py", line 667, in __init__
modifiers, _nominal_rates = _nominal_and_modifiers_from_spec(
File "/home/feickert/Code/GitHub/pyhf/src/pyhf/pdf.py", line 148, in _nominal_and_modifiers_from_spec
finalizd_builder_data[k] = modifiers_builders[k].finalize()
File "/home/feickert/Code/GitHub/pyhf/src/pyhf/modifiers/histosys.py", line 87, in finalize
raise InvalidModifier(
pyhf.exceptions.InvalidModifier: The 'WtZ' sample histosys modifier 'syst_wrongbins' has data shape inconsistent with the sample.
WtZ has 'data' of length 4 but syst_wrongbins has 'lo_data' of length 3 and 'hi_data' of length 3. |
@kratsg This is ready for review again now with patch files. |
c04f43b
to
3aea7ca
Compare
Description
Resolves #1216
Raise an
InvalidModifier
exception if bin-wise modifiers have data that is of a different length than the data for the sample they belong to. The exception attempts to tell the user exactly where the problem is in the spec.This gets applied to
histosys
,shapesys
, andstaterror
modifiers if I have this right.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: