-
Notifications
You must be signed in to change notification settings - Fork 85
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: Expose fitted parameter values of implicit fits in test statistic calls #1554
Conversation
@lhenkelm while you're working on this can you add some commentary as well? It isn't really clear why all of what is in here so far is strictly needed. |
@matthewfeickert the changes are those needed to get access to the ML estimates of the parameters in a call to
So the changes to the implementation code are minimal. The bulk of the new lines are tests and docstrings, I tried to keep the new tests small/generic enough so that they are robust against new changes while covering all of the new behavior. But you guys have the experience of what parts change a lot and how, so let me know if the tests are overbearing! For the docstrings I tried to be super explicit about describing how the return values change with new option and give plenty of examples for people that find those more useful. So in that sense I think these are necessary changes, but if you think it makes the docstrings too bloated, please tell me! |
only introduce in pyhton 3.8
regarding the tests: they all pass locally, except one unrelated test in |
thanks @lhenkelm ! on first glance this looks good, I'll do a more detailed review asap I wonder whether at some point it makes sense to use data classes + strutural pattern matching (PEP 622 ) to replace tuple returns |
One thing that we should discuss is whether we can somehow unify the "data classes" with cabinetry i.e. BestFitParams (or |
I think it would be great to harmonize where possible. Being able to do a |
Conflicts: docs/contributors.rst
for more information, see https://pre-commit.ci
* no asserts about return values other than the calculator * collapse the separate tests into one parametrized test
instead of raising when accessed before self..teststatistic is called, initialise to `None`
Codecov Report
@@ Coverage Diff @@
## master #1554 +/- ##
==========================================
+ Coverage 97.70% 97.71% +0.01%
==========================================
Files 63 63
Lines 4048 4067 +19
Branches 576 581 +5
==========================================
+ Hits 3955 3974 +19
Misses 54 54
Partials 39 39
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I appreciate the 100% coverage here (thanks a lot!). We'll merge this in once we get the all clear. |
Thanks for the PR @lhenkelm! |
It is possible to access the Asimov parameters as well: | ||
|
||
>>> pyhf.infer.calculators.generate_asimov_data( | ||
... mu_test, data, model, None, None, None, | ||
... return_fitted_pars = True | ||
... ) | ||
(array([ 60.61229858, 56.52802479, 270.06832542, 48.31545488]), array([1. , 0.97224597, 0.87553894])) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples should be contiguous else they break the copy button usefulness.
Description
Resolves #1550.
Functions in
pyhf.infer
that callpyhf.infer.mle.fit
orpyhf.infer.mle.fixed_poi_fit
(exceptpyhf.infer.upperlimit
) return the best-fit parameters if they recievereturn_fitted_pars=True
as a kwarg. Thepyhf.infer.calculators.AymptoticCalculator
has an attribute holding the best-fit parameters of the most recent five fits.Checklist Before Requesting Reviewer
Before Merging
For the PR Assignees: