-
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
ValueError: The truth value of an array
... when using fixed_params
kwarg for pyhf.infer.hypotest
#2419
Comments
Hi @andrewfowlie. This is a bug of documentation and another reason we need to get types in at some point. The pyhf/src/pyhf/infer/__init__.py Lines 64 to 65 in 5154cda
but it should be a Here's your example, but working: import pyhf
pyhf.set_backend("numpy")
model = pyhf.simplemodels.uncorrelated_background(
signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
)
observations = [51, 48]
data = pyhf.tensorlib.astensor(observations + model.config.auxdata)
mu_test = 1.0
fixed_params = model.config.suggested_fixed()
fixed_params[1:] = True, True # The POI can't be fixed and still perform inference
print(f"Fixed parameters: {fixed_params}")
cls_obs, cls_exp_band = pyhf.infer.hypotest(
mu_test,
data,
model,
fixed_params=fixed_params,
return_expected_set=True,
test_stat="qtilde",
)
print(f"Observed CLs: {cls_obs}")
print(f"Expected CLs band: {cls_exp_band}")
# tuple is valid too
fixed_params = tuple(fixed_params)
pyhf.infer.hypotest(
mu_test,
data,
model,
fixed_params=fixed_params,
return_expected_set=True,
test_stat="qtilde",
)
|
Thanks Matthew, using a list or tuple works for me. Yes it's a small bug in the docs. |
@andrewfowlie This is now corrected in the |
Thanks Matthew. I think that this affects the init_pars and par_bounds docs too. |
Summary
I can't get the
fixed_params
kwarg ofpyhf.infer.hypotest
to work. Here is a an example from the docs without it that works for meNow, let me try to fix the parameters.
I find
If this is a bug, it you can probably fix this by doing
and it likely affects
init_pars
andpar_bounds
too. Though maybe I am passing the wrong kind of object to the method.OS / Environment
Steps to Reproduce
File Upload (optional)
No response
Expected Results
I expected to compute the CLs with some fixed parameters.
Actual Results
pyhf Version
pyhf, version 0.7.5
Code of Conduct
The text was updated successfully, but these errors were encountered: