Skip to content

Commit dc76ad1

Browse files
docs: Add v0.7.2 failing example to v0.7.3 release notes (#2294)
* As the bug that was fixed in PR #2278 was subtle add an example to the pyhf v0.7.3 release notes that people can use to see if they were affected by it. * Amends PR #2290
1 parent 6dace15 commit dc76ad1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/release-notes/v0.7.3.rst

+49
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,55 @@ Fixes
1414
are correctly handled.
1515
(PRs :pr:`2277`, :pr:`2278`)
1616

17+
The fixed bug was subtle and only occurred for specific configurations of
18+
settings and arguments where ``do_grad=False`` was used (either explicitly
19+
by provided kwarg or implicitly through defaults).
20+
To determine if you might have been affected by it, check your code for
21+
setups like the following.
22+
23+
.. code:: python
24+
25+
# Bug is backend independent. JAX is selected as an example where
26+
# do_grad=False might be selected in response to the backend's value of
27+
# pyhf.tensorlib.default_do_grad being True.
28+
pyhf.set_backend("jax", pyhf.optimize.minuit_optimizer(strategy=0))
29+
30+
...
31+
32+
fit_result, opt_result = pyhf.infer.mle.fit(
33+
data, model, return_result_obj=True, do_grad=False
34+
)
35+
assert opt_result.minuit.strategy.strategy == 0 # fails for pyhf v0.7.2
36+
37+
Full example that fails in ``pyhf`` ``v0.7.2``:
38+
39+
.. code:: python
40+
41+
import pyhf
42+
43+
pyhf.set_backend("jax", pyhf.optimize.minuit_optimizer(strategy=0))
44+
45+
model = pyhf.simplemodels.uncorrelated_background(
46+
signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
47+
)
48+
data = [51, 48] + model.config.auxdata
49+
50+
# passing with strategy kwarg explicitly given
51+
fit_result, opt_result = pyhf.infer.mle.fit(
52+
data, model, return_result_obj=True, do_grad=False, strategy=0
53+
)
54+
minuit_strategy = opt_result.minuit.strategy.strategy
55+
print(f"# Minuit minimization strategy: {minuit_strategy}")
56+
assert minuit_strategy == 0
57+
58+
# strategy kwarg not given
59+
fit_result, opt_result = pyhf.infer.mle.fit(
60+
data, model, return_result_obj=True, do_grad=False
61+
)
62+
minuit_strategy = opt_result.minuit.strategy.strategy
63+
print(f"# Minuit minimization strategy: {minuit_strategy}")
64+
assert minuit_strategy == 0 # fails for pyhf v0.7.2
65+
1766
Contributors
1867
------------
1968

0 commit comments

Comments
 (0)