Skip to content
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

Extend sampler #3

Merged
merged 38 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d154cc8
enable to separation btw aux and main
jackaraz Sep 1, 2023
366f92c
bump the version
jackaraz Sep 1, 2023
a1e592e
add metadata for bkgonly model
jackaraz Sep 1, 2023
c0c926c
bump spey requirement
jackaraz Sep 2, 2023
0a6296a
initialise simplifier
jackaraz Sep 2, 2023
66d86a9
add simplify backend and bump spey version
jackaraz Sep 2, 2023
8e771c0
update sphinx version for compatibility
jackaraz Sep 2, 2023
2d21ee0
extend documentation
jackaraz Sep 4, 2023
d1aec68
extend documentation
jackaraz Sep 4, 2023
3841d81
update api
jackaraz Sep 4, 2023
58d00c7
add changelog
jackaraz Sep 4, 2023
234a33b
update linting
jackaraz Sep 4, 2023
e09555f
update documentation
jackaraz Sep 5, 2023
e6fddad
improve documentation
jackaraz Sep 5, 2023
db0137f
add properties
jackaraz Sep 5, 2023
aacbfc9
bugfixes and optimisation
jackaraz Sep 5, 2023
bb8144a
remove unnecessary imports
jackaraz Sep 5, 2023
bbad22f
bugfix for #5
jackaraz Sep 6, 2023
1fd6778
add helper function to interpret bkg model
jackaraz Sep 6, 2023
ef18bd8
code optimisation and bug fixes
jackaraz Sep 6, 2023
0e1623d
add helper func
jackaraz Sep 6, 2023
be00c85
update change log
jackaraz Sep 6, 2023
adea872
extend doc
jackaraz Sep 6, 2023
1c518fa
enable jit for jax
jackaraz Sep 7, 2023
b5a52a0
update documentation
jackaraz Sep 7, 2023
1318d90
extend the example
jackaraz Sep 7, 2023
feb5a87
add warning management
jackaraz Sep 7, 2023
832e07c
jit is creating issues
jackaraz Sep 11, 2023
fcdb25f
sort imports
jackaraz Sep 13, 2023
48596ce
include signal modifiers
jackaraz Sep 14, 2023
d911f7a
remove jit
jackaraz Sep 14, 2023
c4ab900
extend functionality
jackaraz Sep 14, 2023
4766bf7
extend documentation
jackaraz Sep 14, 2023
c4bff11
extend doc
jackaraz Sep 14, 2023
df1e2e7
update docs
jackaraz Sep 15, 2023
9e4f3d2
Merge pull request #2 from SpeysideHEP/simplifier
jackaraz Sep 15, 2023
da8d0c2
update doc workflow
jackaraz Sep 15, 2023
5701356
update changelog
jackaraz Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: black-action
name: Lint

on:
push:
Expand All @@ -13,25 +13,13 @@ on:
workflow_dispatch:

jobs:
linter_name:
lint:
name: runner / black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check files using the black formatter
uses: rickstaa/action-black@v1
- uses: actions/checkout@v3
- uses: psf/black@stable
id: action_black
with:
black_args: "-l 100 ./src/*"
- name: Create Pull Request
if: steps.action_black.outputs.is_formatted == 'true'
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Format Python code with psf/black push"
commit-message: ":art: Format Python code with psf/black"
body: |
There appear to be some python formatting errors in ${{ github.sha }}. This pull request
uses the [psf/black](https://github.com/psf/black) formatter to fix these issues.
base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
branch: actions/black
options: "-l 100"
src: "./src"
3 changes: 1 addition & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Build Documentation

on:
pull_request:
branches: [ "main" ]
push:
branches: ["main"]
paths: ["**.rst"]
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand Down
33 changes: 32 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Managers
manager.PyhfManager
interface.ModelNotDefined
interface.CombinationError
simplify.ConversionError

Interface
---------
Expand All @@ -26,4 +27,34 @@ Interface
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
:inherited-members:

.. autoclass:: spey_pyhf.simplify.Simplify
:members:
:undoc-members:

Data classes
------------

.. autoclass:: spey_pyhf.data.Base
:members:
:undoc-members:

.. autoclass:: spey_pyhf.data.FullStatisticalModelData
:members:
:undoc-members:
:show-inheritance:
:inherited-members:

.. autoclass:: spey_pyhf.data.SimpleModelData
:members:
:undoc-members:
:show-inheritance:
:inherited-members:

Helper functions
----------------

.. autoclass:: spey_pyhf.WorkspaceInterpreter
:members:
:undoc-members:
2 changes: 1 addition & 1 deletion docs/citations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The BibTeX entry for citing ``spey`` is
year = "2023"
}

This plug-in uses ``pyhf`` internally, thus please also cite the following
This plug-in uses ``pyhf`` internally; thus, please also cite the following

.. code-block:: BibTeX

Expand Down
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@
"sphinxcontrib.bibtex",
"sphinx.ext.napoleon",
"sphinx_click.ext",
# "sphinx_toolbox.collapse", # requires sphinx_toolbox to be installed
"nbsphinx",
"sphinx_issues",
"sphinx_copybutton",
"sphinx_togglebutton",
"sphinx_rtd_size",
"xref",
"myst_parser",
]

# set the width of the page
sphinx_rtd_size_width = "75%"

# external links
xref_links = {
"1007.1727": ("[arXiv:1007.1727]", "https://doi.org/10.48550/arXiv.1007.1727"),
Expand Down
Binary file added docs/figs/atlas_susy_2019_08_simp_obs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ Welcome to the documentation of ``pyhf`` plugin for spey interface
:caption: Contents:

quick_start
simplify
api
citations



Indices and tables
==================
releases/changelog-dev

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
41 changes: 22 additions & 19 deletions docs/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Installation
>>> pip install spey-pyhf


Python >=3.8 is required. This will automatically install ``pyhf`` as well since it is a requirement.
For Gradient and Hessian implementations in likelihood optimisation we recomend also installing ``Jax``.
Python >=3.8 is required. This will also automatically install ``pyhf``since it is a requirement.
For Gradient and Hessian implementations in likelihood optimisation, we recommend also installing ``Jax``.

Once this package is installed, ``spey`` can automatically detect it which can be tested using
Once this package is installed, ``spey`` can automatically detect it, which can be tested using
:func:`~spey.AvailableBackends` function;

.. code-block:: python3
Expand All @@ -25,13 +25,15 @@ Once this package is installed, ``spey`` can automatically detect it which can b
>>> # 'pyhf',
>>> # 'pyhf.uncorrelated_background']

.. _sec_quick_start:

Quick Start
===========

``"pyhf"`` accessor enables user to access all ``pyhf``'s likelihood building capabilities.
The function of this accessor accepts a background only statistical model dictionary as described
in `pyhf's online documentation <https://pyhf.readthedocs.io/en/v0.7.2/likelihood.html>`_. Additinally,
signal patch sample needs to be provided. An example for these two can be found below.
The function of this accessor accepts a background-only statistical model dictionary as described
in `pyhf's online documentation <https://pyhf.readthedocs.io/en/v0.7.2/likelihood.html>`_. Additionally,
a signal patch sample needs to be provided. An example of these two can be found below.

.. code-block:: python3

Expand Down Expand Up @@ -71,8 +73,8 @@ signal patch sample needs to be provided. An example for these two can be found
... }
... ]

where ``background_only`` dictionary refers to the statistical model that encapsulates only the background
and ``signal`` includes the signal only patch set. In the following we demonstrate the usage of these
The ``background_only`` dictionary refers to the statistical model that encapsulates only the background
, and the ``signal`` includes the signal-only patch set. In the following, we demonstrate the usage of these
descriptions within ``spey``;

.. code-block:: python3
Expand All @@ -88,23 +90,24 @@ descriptions within ``spey``;

>>> statistical_model.exclusion_confidence_level() # [0.9474850259721279]

For the rest of the functionalities please refer to the ``spey`` documentation. Due to spey's fully
backend agnostic structure all the functionalities of the :class:`~spey.StatisticalModel` class also
For the rest of the functionalities, please refer to the ``spey`` documentation, which can be found
`in this link <https://speysidehep.github.io/spey/>`_. Due to Spey's fully
backend agnostic structure, all the functionalities of the :class:`~spey.StatisticalModel` class also
applies to ``pyhf`` plug-in.

**Arguments:**

* ``background_only_model``: This is background-only model dictionary which includes information about
background yields, uncertainties and observations. Details on how to construct these dictionaries can be
* ``background_only_model``: This background-only model dictionary includes information about
background yields, uncertainties and observations. Details on constructing these dictionaries can be
found in `pyhf's online documentation <https://pyhf.readthedocs.io/en/v0.7.2/likelihood.html>`_.
* ``signal_patch``: This is signal patch which includes dictionaries describing which regions are going
to be added or removed from the statistical model.
* ``signal_patch``: This signal patch includes dictionaries describing which regions will be added or
removed from the statistical model.
* ``analysis`` (optional): Unique identifier for the analysis.
* ``xsection`` (optional): Cross section value for the signal hypothesis. Units determined by the user.
* ``xsection`` (optional): Cross-section value for the signal hypothesis. Units determined by the user.


Additionally this plug-in is shiped with simple uncorrelated background attachment which accesses
``pyhf``'s ``uncorrelated_backgound`` function which can be accessed through spey with following function
Additionally, this plug-in is shipped with simple uncorrelated background-attachment which accesses
``pyhf``'s ``uncorrelated_backgound`` function can be accessed through spey with the following function

.. code-block:: python3

Expand Down Expand Up @@ -135,12 +138,12 @@ Additionally this plug-in is shiped with simple uncorrelated background attachme
* ``data``: observations as a list.
* ``absolute_uncertainties``: uncertainties on the background as a list.
* ``analysis`` (optional): Unique identifier for the analysis.
* ``xsection`` (optional): Cross section value for the signal hypothesis. Units determined by the user.
* ``xsection`` (optional): Cross-section value for the signal hypothesis. Units determined by the user.


.. note::

``pyhf`` offers an interface to combine the likelihoods that are described as JSON serialised
files. This has been exploited in ``spey`` interface via :func:`combine` `function <https://speysidehep.github.io/spey/api.html#spey.StatisticalModel.combine>`_.
This function combines pyhf workspaces and adjust the signal structure accordingly. For more information
This function combines ``pyhf`` workspaces and adjusts the signal structure accordingly. For more information
about how ``pyhf`` handles the workspace combination `see the dedicated tutorial here <https://pyhf.github.io/pyhf-tutorial/Combinations.html>`_.
28 changes: 28 additions & 0 deletions docs/releases/changelog-v0.1.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Release notes v0.1.1

## New features since last release

* A mapping functionality has been developed between ``pyhf``'s full
statistical models and simplified likelihoods framework. Methodology
and usage can be found in the online documentation.
([#2](https://github.com/SpeysideHEP/spey-pyhf/pull/2))

## Improvements

* Sampler functionality has been extended to isolate auxiliary data.
([#3](https://github.com/SpeysideHEP/spey-pyhf/pull/3))

* Fixed parameters have been added to the constraints list.
([#2](https://github.com/SpeysideHEP/spey-pyhf/pull/2))

## Bug fixes

* Bugfix in apriori likelihood computation for full likelihoods mentioned in
[#5](https://github.com/SpeysideHEP/spey-pyhf/issues/5).
([#2](https://github.com/SpeysideHEP/spey-pyhf/pull/2))

## Contributors

This release contains contributions from (in alphabetical order):

* [Jack Araz](https://github.com/jackaraz)
Loading