-
Notifications
You must be signed in to change notification settings - Fork 84
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
Type of suggested bounds changes when specified in model config #1755
Comments
I believe a change could maybe be introduced here Lines 29 to 41 in 270d59d
pyhf/src/pyhf/parameters/utils.py Line 10 in 270d59d
An addition of if parameter.get("bounds"):
parameter["bounds"] = [tuple(parameter["bounds"][0])] before the |
JSON doesn't know about tuples vs lists fyi. But in your code example, what happens with spec["measurements"][0]["config"]["parameters"].append({"name": "mu", "bounds": [(0, 10)]}) instead? You are appending bounds as a list.. and as far as the code is aware/concerned, that's not an issue? Ok, maybe your description is not clear - but is the issue that specifying the bounds or changing it -- from the default -- is what causes it to be injected as a list, even if you specify a tuple? but you didn't specify a tuple here. EDIT: I see. JSON schema doesn't know how to treat tuples in python (because they're not really arrays) which is why the bounds come out like this. Edit 2: see python-jsonschema/jsonschema#148 |
Sorry if the example was misleading, when appending
Yes, as soon as I manually specify the bounds in the measurement config (independent of whether or not the numbers I specify are the defaults anyway), the specific entry will be a list. I caught this during dynamic type checking. Having uniform behavior would make typing a bit cleaner. |
The solution is probably to have type-checking to only specify the bounds as tuples I think (from the python code) but then also convert the bounds loaded from the JSON file to tuples... Need to think more because this breaks some minor portion of the code. |
Summary
The per-parameter bounds from
model.config.suggested_bounds()
are tuples by default, but become lists when specified in the specification via the model config section. For consistency, it would be useful to stick with tuples. Happy to help look into and harmonize this.OS / Environment
n/a
Steps to Reproduce
output:
File Upload (optional)
No response
Expected Results
A
List[Tuple[float, float]]
in both cases:[(0, 10), (1e-10, 10.0)]
.Actual Results
Specifying the bounds manually changes that part of the list from a tuple to a list.
[[0, 10], (1e-10, 10.0)]
pyhf Version
0.6.3 / master
Code of Conduct
The text was updated successfully, but these errors were encountered: