Skip to content

Commit f5ff11c

Browse files
authored
Merge pull request #45 from SpeysideHEP/negative_poi
[feat] Implementation of two-sided tests with lower and upper bounds on the POI
2 parents d1b38f6 + c3b5d8e commit f5ff11c

32 files changed

+698
-290
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Check/Build/Deploy
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches: ["releases/**"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
check:
12+
name: OS ${{ matrix.os }}, Python ${{ matrix.python-version }}
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
19+
os: [ubuntu-latest, macos-latest]
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install pytest pytest-cov
31+
python -m pip install -e .
32+
- name: Test with pytest
33+
run: |
34+
python -c 'import spey;spey.about()'
35+
pytest --cov=spey tests/*py #--cov-fail-under 99
36+
37+
build:
38+
name: Build wheel
39+
runs-on: ubuntu-latest
40+
needs: check
41+
steps:
42+
- name: Checkout git repository
43+
uses: actions/checkout@v4
44+
45+
- name: Build Spey wheel
46+
run: |
47+
python -m pip install --upgrade pip
48+
python -m pip install wheel
49+
python setup.py bdist_wheel
50+
51+
- name: Upload wheels as artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: wheel
55+
path: ./dist/*.whl
56+
57+
deploy:
58+
if: ${{ !github.event.release.prerelease && !contains(github.ref, '-rc') && !contains(github.ref, '-beta') && !contains(github.ref, '-alpha') }}
59+
runs-on: ubuntu-latest
60+
needs: build
61+
permissions:
62+
id-token: write
63+
steps:
64+
- uses: actions/download-artifact@v4
65+
with:
66+
pattern: wheel
67+
merge-multiple: true
68+
path: dist
69+
70+
- name: Debug
71+
run: ls -l dist
72+
73+
- uses: pypa/gh-action-pypi-publish@v1.12.4
74+
with:
75+
user: ${{ secrets.TWINE_USERNAME }}
76+
password: ${{ secrets.TWINE_PSSWRD }}
77+
repository-url: https://pypi.org/project/spey/

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12.6"]
21+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2222
os: [ubuntu-latest, macos-latest]
2323

2424
steps:

.zenodo.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"description": "smooth inference for reinterpretation studies",
33
"license": "MIT",
4-
"title": "SpeysideHEP/spey: v0.1.11",
5-
"version": "v0.1.11",
4+
"title": "SpeysideHEP/spey: v0.2.0",
5+
"version": "v0.2.0",
66
"upload_type": "software",
77
"creators": [
88
{
@@ -31,7 +31,7 @@
3131
},
3232
{
3333
"scheme": "url",
34-
"identifier": "https://github.com/SpeysideHEP/spey/tree/v0.1.11",
34+
"identifier": "https://github.com/SpeysideHEP/spey/tree/v0.2.0",
3535
"relation": "isSupplementTo"
3636
},
3737
{

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ Finally, the name "Spey" originally comes from the Spey River, a river in the mi
5555

5656
| Accessor | Description |
5757
| --------------------------------------- | ---------------------------------------------------------------------------- |
58-
| ``"default_pdf.uncorrelated_background"`` | Constructs uncorrelated multi-bin statistical model. |
59-
| ``"default_pdf.correlated_background"`` | Constructs correlated multi-bin statistical model with Gaussian nuisances. |
60-
| ``"default_pdf.third_moment_expansion"`` | Implements the skewness of the likelihood by using third moments. |
61-
| ``"default_pdf.effective_sigma"`` | Implements the skewness of the likelihood by using asymmetric uncertainties. |
62-
| ``"default_pdf.poisson"`` | Implements simple Poisson-based likelihood without uncertainties. |
63-
| ``"default_pdf.normal"`` | Implements Normal distribution. |
64-
| ``"default_pdf.multivariate_normal"`` | Implements Multivariate normal distribution. |
58+
| ``"default.uncorrelated_background"`` | Constructs uncorrelated multi-bin statistical model. |
59+
| ``"default.correlated_background"`` | Constructs correlated multi-bin statistical model with Gaussian nuisances. |
60+
| ``"default.third_moment_expansion"`` | Implements the skewness of the likelihood by using third moments. |
61+
| ``"default.effective_sigma"`` | Implements the skewness of the likelihood by using asymmetric uncertainties. |
62+
| ``"default.poisson"`` | Implements simple Poisson-based likelihood without uncertainties. |
63+
| ``"default.normal"`` | Implements Normal distribution. |
64+
| ``"default.multivariate_normal"`` | Implements Multivariate normal distribution. |
6565
| ``"pyhf.uncorrelated_background"`` | Uses uncorrelated background functionality of pyhf (see [``spey-phyf`` plugin](https://github.com/SpeysideHEP/spey-pyhf)). |
6666
| ``"pyhf"`` | Uses generic likelihood structure of pyhf (see [``spey-phyf`` plugin](https://github.com/SpeysideHEP/spey-pyhf)) |
6767

@@ -75,17 +75,17 @@ likelihood prescriptions which can be checked via `AvailableBackends` function
7575
```python
7676
import spey
7777
print(spey.AvailableBackends())
78-
# ['default_pdf.correlated_background',
79-
# 'default_pdf.effective_sigma',
80-
# 'default_pdf.third_moment_expansion',
81-
# 'default_pdf.uncorrelated_background']
78+
# ['default.correlated_background',
79+
# 'default.effective_sigma',
80+
# 'default.third_moment_expansion',
81+
# 'default.uncorrelated_background']
8282
```
8383

84-
Using ``'default_pdf.uncorrelated_background'`` one can simply create single or multi-bin
84+
Using ``'default.uncorrelated_background'`` one can simply create single or multi-bin
8585
statistical models:
8686

8787
```python
88-
pdf_wrapper = spey.get_backend('default_pdf.uncorrelated_background')
88+
pdf_wrapper = spey.get_backend('default.uncorrelated_background')
8989

9090
data = [1]
9191
signal_yields = [0.5]
@@ -147,7 +147,7 @@ collaborations to estimate the difference from the Standard Model rather than th
147147
One can play the same game using the same backend for multi-bin histograms as follows;
148148

149149
```python
150-
pdf_wrapper = spey.get_backend('default_pdf.uncorrelated_background')
150+
pdf_wrapper = spey.get_backend('default.uncorrelated_background')
151151

152152
data = [36, 33]
153153
signal = [12.0, 15.0]

docs/bib/cited.bib

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
@article{Ghosh:2024puc,
2+
author = {Ghosh, Kirtiman and Huitu, Katri and Sahu, Rameswar},
3+
title = {{Revisiting Universal Extra-Dimension Model with Gravity Mediated Decays}},
4+
eprint = {2412.09344},
5+
archiveprefix = {arXiv},
6+
primaryclass = {hep-ph},
7+
month = {12},
8+
year = {2024},
9+
journal = {}
10+
}
11+
12+
113
@article{Goodsell:2024aig,
214
author = {Goodsell, Mark D.},
315
title = {{HackAnalysis 2: A powerful and hackable recasting tool}},
@@ -15,25 +27,29 @@ @article{Agin:2024yfs
1527
eprint = {2404.12423},
1628
archiveprefix = {arXiv},
1729
primaryclass = {hep-ph},
18-
month = {4},
19-
year = {2024},
20-
journal = {}
30+
doi = {10.1140/epjc/s10052-024-13594-9},
31+
journal = {Eur. Phys. J. C},
32+
volume = {84},
33+
number = {11},
34+
pages = {1218},
35+
year = {2024}
2136
}
2237

2338

2439
@article{Feike:2024zfz,
25-
archiveprefix = {arXiv},
2640
author = {Feike, Alexander and Fiaschi, Juri and Fuks, Benjamin and Klasen, Michael and Puck Neuwirth, Alexander},
41+
title = {{Combination and reinterpretation of LHC SUSY searches}},
2742
eprint = {2403.11715},
28-
month = {3},
43+
archiveprefix = {arXiv},
2944
primaryclass = {hep-ph},
3045
reportnumber = {MS-TP-23-49},
31-
title = {{Combination and Reinterpretation of LHC SUSY Searches}},
32-
year = {2024},
33-
journal = {}
46+
doi = {10.1007/JHEP07(2024)122},
47+
journal = {JHEP},
48+
volume = {07},
49+
pages = {122},
50+
year = {2024}
3451
}
3552

36-
3753
@article{Elmer:2023wtr,
3854
author = {Elmer, Nina and Madigan, Maeve and Plehn, Tilman and Schmal, Nikita},
3955
title = {{Staying on Top of SMEFT-Likelihood Analyses}},

docs/comb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Let us first import all the necessary packages and construct the data (please ad
3939
>>> models = {}
4040
>>> # loop overall data
4141
>>> for data in example_data["data"]:
42-
>>> pdf_wrapper = spey.get_backend("default_pdf.uncorrelated_background")
42+
>>> pdf_wrapper = spey.get_backend("default.uncorrelated_background")
4343
4444
>>> stat_model = pdf_wrapper(
4545
... signal_yields=data["signal_yields"],

docs/exclusion.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The `allow_negative_signal` keyword controls which test statistic is used and re
7373

7474
For complex statistical models, optimizing the likelihood can be challenging and depends on the choice of optimizer. Spey uses SciPy for optimization and fitting tasks. Any additional keyword arguments not explicitly covered in the {func}`~spey.StatisticalModel.exclusion_confidence_level` function description are passed directly to the optimizer, allowing users to customize its behavior through the interface.
7575

76-
Below we compare the exclusion limits computed with each approach. This comparisson uses normal distribution for the likelihood ([`default_pdf.normal`](#normal)) background yields are set to $n_b$, uncertainties are shown with $\sigma$ and observations are given with $n$.
76+
Below we compare the exclusion limits computed with each approach. This comparisson uses normal distribution for the likelihood ([`default.normal`](#normal)) background yields are set to $n_b$, uncertainties are shown with $\sigma$ and observations are given with $n$.
7777

7878
```{figure} ./figs/comparisson_observed.png
7979
---
@@ -90,7 +90,7 @@ exclusion limit calculator comparisson for observed p-values
9090
```{code-cell} ipython3
9191
import spey
9292
93-
stat_wrapper = spey.get_backend("default_pdf.normal")
93+
stat_wrapper = spey.get_backend("default.normal")
9494
statistical_model = stat_wrapper(
9595
signal_yields=[3.0],
9696
background_yields=[2.0],

0 commit comments

Comments
 (0)