Skip to content

Commit d2f0268

Browse files
committed
add precommit
1 parent 807de14 commit d2f0268

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+395
-299
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ body:
99
value: |
1010
## Before posting a feature request
1111
Search existing [GitHub issues](https://github.com/SpeysideHEP/spey/issues) to make sure the issue does not already exist.
12-
12+
1313
* **Please use [Markdown syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).**
1414
- type: textarea
1515
id: system
@@ -63,4 +63,3 @@ body:
6363
options:
6464
- label: I have searched existing GitHub issues to make sure the issue does not already exist.
6565
required: true
66-

.github/ISSUE_TEMPLATE/question.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ body:
1010
## Before posting a question
1111
1212
Search existing [GitHub issues](https://github.com/SpeysideHEP/spey/issues) to make sure the issue does not already exist.
13-
13+
1414
If your question involves software issues, please include your system settings as shown below;
15-
15+
1616
**System Settings:**
1717
Please copy and paste the output of `spey.about()` function. If you are working on a specific branch please add the name of the branch and last commit ID. The abbreviated commit ID can be found via `git log -n1 --format="%h"` command. To retreive the branch name please use `git rev-parse --abbrev-ref HEAD` command.)
1818
- type: textarea
@@ -21,7 +21,7 @@ body:
2121
label: Question
2222
description: |
2323
How can we help?
24-
24+
2525
* **Please use [Markdown syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).**
2626
validations:
2727
required: true

.github/workflows/docs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/setup-python@v3
3434
with:
3535
python-version: ${{ matrix.python-version }}
36-
36+
3737
- name: Install dependencies
3838
run: |
3939
python -m pip install --upgrade pip
@@ -44,7 +44,7 @@ jobs:
4444
- name: Compile Docs
4545
run: |
4646
cd docs; make clean; make html; cd ..
47-
47+
4848
- name: Fix permissions if needed
4949
run: |
5050
chmod -c -R +rX "docs/_build/html/" | while read line; do
@@ -77,4 +77,4 @@ jobs:
7777

7878
- name: Deploy to GitHub Pages
7979
id: deployment
80-
uses: actions/deploy-pages@v2
80+
uses: actions/deploy-pages@v2

.github/workflows/pre-commit.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
on:
2+
pull_request:
3+
branches: ["main", "releases/**"]
4+
push:
5+
branches: ["main", "releases/**", "testing"]
6+
7+
name: Check if pre-commit checks pass
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.8"
17+
- uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: trailing-whitespace
7+
- id: check-added-large-files
8+
args: ["--maxkb=1024"]
9+
- id: check-ast
10+
- id: check-docstring-first
11+
- id: check-merge-conflict
12+
- id: check-symlinks
13+
- id: check-yaml
14+
- id: forbid-submodules
15+
16+
- repo: https://github.com/asottile/pyupgrade
17+
rev: v3.3.1
18+
hooks:
19+
- id: pyupgrade
20+
args: [--py38-plus]
21+
language_version: python3.8
22+
23+
- repo: https://github.com/pre-commit/pygrep-hooks
24+
rev: v1.10.0
25+
hooks:
26+
- id: rst-directive-colons
27+
- id: rst-inline-touching-normal
28+
29+
- repo: https://github.com/psf/black
30+
rev: 22.6.0
31+
hooks:
32+
- id: black
33+
args: ["--line-length=90", "--target-version=py38"]
34+
language_version: python3.8

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ python:
2323
install:
2424
- requirements: docs/requirements.txt
2525
- method: pip
26-
path: .
26+
path: .

.zenodo.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@
4040
"relation": "isDocumentedBy"
4141
}
4242
]
43-
}
43+
}

CITATIONS.bib

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ @software{spey_zenodo
2222
version = {v0.1.11},
2323
doi = {10.5281/zenodo.14071351},
2424
url = {https://doi.org/10.5281/zenodo.14071351}
25-
}
25+
}

Makefile

-5
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,3 @@ testpypi:
3131
.PHONY: pypi
3232
pypi:
3333
python3 -m twine upload -r pypi dist/*
34-
35-
36-
37-
38-

data/path_finder/example_data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2942,4 +2942,4 @@
29422942
]
29432943
}
29442944
]
2945-
}
2945+
}

docs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Makefile for Sphinx documentation
1+
# Makefile for Sphinx documentation
22

33
SPHINXOPTS = -W --keep-going #-n
44
SPHINXBUILD = sphinx-build

docs/_static/css/custom.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ span#release {
4545
width: 200px;
4646
margin-right: 50px;
4747
line-height: 22px;
48-
}
48+
}

docs/api.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Top-Level
1111

1212
.. currentmodule:: spey
1313

14-
.. autosummary::
14+
.. autosummary::
1515
:toctree: _generated/
1616

1717
version
@@ -68,7 +68,7 @@ Hypothesis testing
6868

6969
.. currentmodule:: spey.hypothesis_testing
7070

71-
.. autosummary::
71+
.. autosummary::
7272
:toctree: _generated/
7373

7474
test_statistics.qmu
@@ -91,7 +91,7 @@ Gradient Tools
9191

9292
.. currentmodule:: spey.math
9393

94-
.. autosummary::
94+
.. autosummary::
9595
:toctree: _generated/
9696

9797
value_and_grad
@@ -105,7 +105,7 @@ Distributions
105105

106106
.. currentmodule:: spey.backends.distributions
107107

108-
.. autosummary::
108+
.. autosummary::
109109
:toctree: _generated/
110110

111111
Poisson
@@ -119,7 +119,7 @@ Default PDFs
119119

120120
.. currentmodule:: spey.backends.default_pdf
121121

122-
.. autosummary::
122+
.. autosummary::
123123
:toctree: _generated/
124124

125125
DefaultPDFBase
@@ -133,7 +133,7 @@ Default PDFs
133133
Simple PDFs
134134
~~~~~~~~~~~
135135

136-
.. autosummary::
136+
.. autosummary::
137137
:toctree: _generated/
138138

139139
simple_pdf.Poisson
@@ -146,7 +146,7 @@ Exceptions
146146

147147
.. currentmodule:: spey.system.exceptions
148148

149-
.. autosummary::
149+
.. autosummary::
150150
:toctree: _generated/
151151
:nosignatures:
152152

docs/bib/references.bib

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,4 @@ @article{Araz:2023bwx
193193
reportnumber = {IPPP/23/34},
194194
month = {7},
195195
year = {2023}
196-
}
196+
}

docs/bibliography.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Bibliography
22
============
33

4-
.. bibliography:: bib/references.bib
4+
.. bibliography:: bib/references.bib

docs/citations.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The BibTeX entry for citing ``spey`` including latest zenodo archive:
1111
.. note::
1212

1313
To retrieve the latest BibTeX information one can also use :func:`~spey.cite` function.
14-
This function pulls the publication information from Inspire-HEP and uses the repository
15-
identification to pull the latest Zenodo archive information.
14+
This function pulls the publication information from Inspire-HEP and uses the repository
15+
identification to pull the latest Zenodo archive information.
1616

1717
.. code-block:: bibtex
1818
@@ -40,4 +40,4 @@ An up-to-date list can be found on `Inspire-HEP <https://inspirehep.net/literatu
4040
.. bibliography:: bib/cited.bib
4141
:all:
4242
:style: unsrtalpha
43-
:list: enumerated
43+
:list: enumerated

docs/comb.rst

+20-20
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ Combining Statistical Models
77
:property=og:image: https://spey.readthedocs.io/en/main/_static/spey-logo.png
88
:property=og:url: https://spey.readthedocs.io/en/main/comb.html
99

10-
In this section, we will provide a simple statistical model combination example using
11-
`Path Finder algorithm <https://github.com/J-Yellen/PathFinder>`_
10+
In this section, we will provide a simple statistical model combination example using
11+
`Path Finder algorithm <https://github.com/J-Yellen/PathFinder>`_
1212
(For details, see :cite:`Araz:2022vtr`).
1313

1414
The data, necessary to complete this exercise, has been provided under the ``data/path_finder`` folder of
1515
`spey's GitHub repository <https://github.com/SpeysideHEP/spey>`_. Here, one will find ``example_data.json``
16-
and ``overlap_matrix.csv`` files. Both files are generated using MadAnalysis 5 recast of ATLAS-SUSY-2018-31
17-
:cite:`ATLAS:2019gdh, DVN/IHALED_2020, Araz:2020stn`
16+
and ``overlap_matrix.csv`` files. Both files are generated using MadAnalysis 5 recast of ATLAS-SUSY-2018-31
17+
:cite:`ATLAS:2019gdh, DVN/IHALED_2020, Araz:2020stn`
1818
and CMS-SUS-19-006 :cite:`CMS:2019zmd, Mrowietz:2020ztq` analyses.
1919

2020
* ``example_data.json``: Includes cross section and signal, background, and observed yield information
2121
for this example.
2222
* ``overlap_matrix.csv``: Includes overlap matrix that the PathFinder algorithm needs to find the best combination.
2323

24-
Let us first import all the necessary packages and construct the data (please add the Pathfinder path to
24+
Let us first import all the necessary packages and construct the data (please add the Pathfinder path to
2525
``sys.path`` list if needed)
2626

2727
.. code-block:: python3
@@ -35,12 +35,12 @@ Let us first import all the necessary packages and construct the data (please ad
3535
>>> with open("example_data.json", "r") as f:
3636
>>> example_data = json.load(f)
3737
38-
38+
3939
>>> models = {}
4040
>>> # loop overall data
4141
>>> for data in example_data["data"]:
4242
>>> pdf_wrapper = spey.get_backend("default_pdf.uncorrelated_background")
43-
43+
4444
>>> stat_model = pdf_wrapper(
4545
... signal_yields=data["signal_yields"],
4646
... background_yields=data["background_yields"],
@@ -49,23 +49,23 @@ Let us first import all the necessary packages and construct the data (please ad
4949
... analysis=data["region"],
5050
... xsection=example_data["xsec"],
5151
... )
52-
52+
5353
>>> llhr = stat_model.chi2(
5454
... poi_test=1.0, poi_test_denominator=0.0, expected=spey.ExpectationType.apriori
5555
... ) / 2.0
56-
56+
5757
>>> models.update({data["region"]: {"stat_model": stat_model, "llhr": llhr}})
5858
59-
``example_data`` has two main section which are ``"data"`` including all the information about regions
59+
``example_data`` has two main section which are ``"data"`` including all the information about regions
6060
and ``"xsec"`` including cross section value in pb. Using the information provided for each region we construct
6161
an uncorrelated background-based statistical model. ``llhr`` is the log-likelihood ratio of signal+background and
6262
background-only statistical models given as
6363

64-
.. math::
64+
.. math::
6565
6666
{\rm llhr} = -\log\frac{\mathcal{L}(1,\theta_1)}{\mathcal{L}(0,\theta_0)}\ .
6767
68-
Finally, the dictionary called ``models`` is just a container to collect all the models. In the next, let us
68+
Finally, the dictionary called ``models`` is just a container to collect all the models. In the next, let us
6969
construct a Binary acceptance matrix and compute the best possible paths
7070

7171
.. code-block:: python3
@@ -80,7 +80,7 @@ construct a Binary acceptance matrix and compute the best possible paths
8080
>>> plot_results.plot(bam, whdfs)
8181
8282
In the first three lines, we read the overlap matrix, extracted the corresponding weights (``llhr``), and fed these
83-
into the ``pf.BinaryAcceptance`` function. We use the ``WHDFS`` algorithm to compute the top 5 combinations and plot the
83+
into the ``pf.BinaryAcceptance`` function. We use the ``WHDFS`` algorithm to compute the top 5 combinations and plot the
8484
resulting binary acceptance matrix with the paths.
8585

8686
.. image:: ./figs/bam.png
@@ -90,11 +90,11 @@ resulting binary acceptance matrix with the paths.
9090

9191
Each column and row corresponds to ``overlap_matrix.columns``, and the coloured lines are the chosen paths
9292
where the best path can be seen via ``whdfs.best.path``. In this case we find ``"atlas_susy_2018_31::SRA_H"``,
93-
``"cms_sus_19_006::SR25_Njet23_Nb2_HT6001200_MHT350600"`` and ``'cms_sus_19_006::AGGSR7_Njet2_Nb2_HT600_MHT600'``
94-
regions as best regions to be combined. For the combination, we will use :obj:`~spey.UnCorrStatisticsCombiner`
93+
``"cms_sus_19_006::SR25_Njet23_Nb2_HT6001200_MHT350600"`` and ``'cms_sus_19_006::AGGSR7_Njet2_Nb2_HT600_MHT600'``
94+
regions as best regions to be combined. For the combination, we will use :obj:`~spey.UnCorrStatisticsCombiner`
9595
and feed the statistical models as input.
9696

97-
.. code-block::
97+
.. code-block::
9898
9999
>>> regions = [
100100
... "atlas_susy_2018_31::SRA_H",
@@ -105,7 +105,7 @@ and feed the statistical models as input.
105105
>>> combined.exclusion_confidence_level(expected=spey.ExpectationType.aposteriori)[2]
106106
>>> # 0.9858284831278277
107107
108-
.. note::
108+
.. note::
109109

110110
:obj:`~spey.UnCorrStatisticsCombiner` can be used for any backend retrieved via :func:`spey.get_backend`
111111
function, which wraps the likelihood prescription with :obj:`~spey.StatisticalModel`.
@@ -117,7 +117,7 @@ the stack, which can be found via
117117
.. code-block:: python3
118118
119119
>>> poiUL = np.array([models[reg]["stat_model"].poi_upper_limit(expected=spey.ExpectationType.aposteriori) for reg in models.keys()])
120-
120+
121121
122122
In our case, the minimum value that we found was from ``"atlas_susy_2018_31::SRA_H"`` where the expected exclusion
123123
limit can be computed via
@@ -127,7 +127,7 @@ limit can be computed via
127127
>>> models["atlas_susy_2018_31::SRA_H"]["stat_model"].exclusion_confidence_level(expected=spey.ExpectationType.aposteriori)[2]
128128
>>> # 0.9445409288935508
129129
130-
Finally, we can compare the likelihood distribution of the two
130+
Finally, we can compare the likelihood distribution of the two
131131

132132
.. code-block:: python3
133133
:linenos:
@@ -154,7 +154,7 @@ which gives us the following result:
154154
:scale: 20
155155
:alt: Binary Acceptance Matrix
156156

157-
.. attention::
157+
.. attention::
158158

159159
The results can vary between scipy versions and the versions of its compilers due to their effect on
160160
optimisation algorithm.

0 commit comments

Comments
 (0)