spey-pyhf
About
spey-pyhf is a pyhf plug-in for the spey statistical inference interface. It exposes pyhf's full likelihood-building machinery — including HistFactory-style JSON workspaces and signal patches — through Spey's backend-agnostic API, so any analysis that ships a pyhf likelihood can be consumed by Spey alongside other backends. Once installed, Spey automatically detects the plug-in and registers three backends: pyhf (full statistical model from a background-only workspace plus a signal patch), pyhf.uncorrelated_background (a lightweight uncorrelated-background helper) and pyhf.simplify (workspace simplification).
Installation
The plug-in is published on PyPI and can be installed with:
python -m pip install spey-pyhf
To install directly from the main branch:
python -m pip install --upgrade "git+https://github.com/SpeysideHEP/spey-pyhf"
Note that the main branch may not be the stable version.
Quick example
Given a pyhf background-only workspace and a signal patch, you can build a Spey statistical model and compute the exclusion confidence level in a few lines:
import spey
background_only = {
"channels": [
{
"name": "singlechannel",
"samples": [
{
"name": "background",
"data": [50.0, 52.0],
"modifiers": [
{"name": "uncorr_bkguncrt", "type": "shapesys", "data": [3.0, 7.0]}
],
}
],
}
],
"observations": [{"name": "singlechannel", "data": [51.0, 48.0]}],
"measurements": [{"name": "Measurement", "config": {"poi": "mu", "parameters": []}}],
"version": "1.0.0",
}
signal_patch = [
{
"op": "add",
"path": "/channels/0/samples/1",
"value": {
"name": "signal",
"data": [12.0, 11.0],
"modifiers": [{"name": "mu", "type": "normfactor", "data": None}],
},
}
]
wrapper = spey.get_backend("pyhf")
model = wrapper(
analysis="simple_pyhf",
background_only_model=background_only,
signal_patch=signal_patch,
)
print(model.exclusion_confidence_level()) # [0.9474850259721279]
Because Spey is fully backend-agnostic, every method of spey.StatisticalModel (likelihood scans, upper limits, combinations, etc.) works the same way on top of pyhf. For the full API and tutorials, see the online documentation.
Metadata
Release files for spey-pyhf 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spey_pyhf-0.2.2.tar.gz | 41.1 kB | Without provenance | Details for spey_pyhf-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spey_pyhf-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for spey_pyhf-0.2.2-py3-none-any.whl |
Total release size: 77.0 kB
Release files / spey_pyhf-0.2.2.tar.gz
| Download URL | spey_pyhf-0.2.2.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43f44bcc7bb045b74c9b40d914d30f38f29c160e580d50c4aa7148916f23c97f
|
|
BLAKE2b-256 checksum How to use checksums |
bc4e70c959f99a38ec9f1b3336c9799a4c324e7bd2f9e86cdff93eef0434d4c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / spey_pyhf-0.2.2-py3-none-any.whl
| Download URL | spey_pyhf-0.2.2-py3-none-any.whl |
|---|---|
| Size | 36.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a52c3da2c09253d1b79596abcc06b300bc85d66baae50e98e45bb42e0eb7bcf1
|
|
BLAKE2b-256 checksum How to use checksums |
491db7f7fd364f756d4fc372792be4e857831d5ed64259ac02dbfb035652baad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Security for spey-pyhf 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.