Metadata-Version: 2.1
Name: simplify-hep
Version: 0.1.2
Summary: Produce simplified likelihoods of different formats
Home-page: UNKNOWN
Author: Eric Schanet
License: BSD 3-Clause
Project-URL: Source, https://github.com/eschanet/simplify
Project-URL: Tracker, https://github.com/eschanet/simplify/issues
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: License :: OSI Approved :: BSD License
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: pyhf[minuit] (>=0.5.3)
Requires-Dist: boost-histogram
Requires-Dist: awkward1
Provides-Extra: complete
Requires-Dist: black ; extra == 'complete'
Requires-Dist: bump2version ; extra == 'complete'
Requires-Dist: flake8 ; extra == 'complete'
Requires-Dist: flake8-bugbear ; extra == 'complete'
Requires-Dist: flake8-import-order ; extra == 'complete'
Requires-Dist: flake8-print ; extra == 'complete'
Requires-Dist: matplotlib ; extra == 'complete'
Requires-Dist: mypy ; extra == 'complete'
Requires-Dist: pre-commit ; extra == 'complete'
Requires-Dist: pydocstyle ; extra == 'complete'
Requires-Dist: pytest ; extra == 'complete'
Requires-Dist: pytest-cov (>=2.5.1) ; extra == 'complete'
Requires-Dist: twine ; extra == 'complete'
Requires-Dist: typeguard ; extra == 'complete'
Provides-Extra: contrib
Requires-Dist: matplotlib ; extra == 'contrib'
Provides-Extra: develop
Requires-Dist: black ; extra == 'develop'
Requires-Dist: bump2version ; extra == 'develop'
Requires-Dist: flake8 ; extra == 'develop'
Requires-Dist: flake8-bugbear ; extra == 'develop'
Requires-Dist: flake8-import-order ; extra == 'develop'
Requires-Dist: flake8-print ; extra == 'develop'
Requires-Dist: matplotlib ; extra == 'develop'
Requires-Dist: mypy ; extra == 'develop'
Requires-Dist: pre-commit ; extra == 'develop'
Requires-Dist: pydocstyle ; extra == 'develop'
Requires-Dist: pytest ; extra == 'develop'
Requires-Dist: pytest-cov (>=2.5.1) ; extra == 'develop'
Requires-Dist: twine ; extra == 'develop'
Requires-Dist: typeguard ; extra == 'develop'
Provides-Extra: test
Requires-Dist: black ; extra == 'test'
Requires-Dist: flake8 ; extra == 'test'
Requires-Dist: flake8-bugbear ; extra == 'test'
Requires-Dist: flake8-import-order ; extra == 'test'
Requires-Dist: flake8-print ; extra == 'test'
Requires-Dist: matplotlib ; extra == 'test'
Requires-Dist: mypy ; extra == 'test'
Requires-Dist: pydocstyle ; extra == 'test'
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: pytest-cov (>=2.5.1) ; extra == 'test'
Requires-Dist: typeguard ; extra == 'test'

# simplify

[![CI status](https://github.com/eschanet/simplify/workflows/CI/badge.svg)](https://github.com/eschanet/simplify/actions?query=workflow%3ACI)
[![Documentation Status](https://readthedocs.org/projects/simplify-hep/badge/?version=latest)](https://simplify-hep.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/eschanet/simplify/branch/master/graph/badge.svg)](https://codecov.io/gh/eschanet/simplify)
[![PyPI version](https://badge.fury.io/py/simplify-hep.svg)](https://badge.fury.io/py/simplify-hep)
[![python version](https://img.shields.io/pypi/pyversions/simplify-hep.svg)](https://pypi.org/project/simplify-hep/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

A package that creates simplified likelihoods from full likelihoods. Currently, only one form of simplified likelihoods is implemented, but the idea is to implement additional versions of the simplified likelihoods, such that the user can chose the one he likes the most (or needs the most).

## Installation

Follow good practice and start by creating a virtual environment

```sh
python3 -m venv simplify
```

and then activating it

```sh
source simplify/bin/activate
```

### Default install

Install the package with pip

```sh
python3 -m pip install simplify-hep[contrib]
```

### Development install

If you want to contribute to `simplify`, install the development version of the package. Fork the repository, clone the fork, and then install

```sh
python3 -m pip install --ignore-installed -U -e .[complete]
```

Next, setup the git pre-commit hook for Black

```sh
pre-commit install
```

You caan run all the tests with

```sh
python3 -m pytest
```

## How to run

### CLI

Run with e.g.

```sh
simplify convert < fullLH.json > simplifiedLH.json
```

or e.g.

```sh
curl http://fo/likelihood.json | simplify convert
```

where `fullLH.json` is the full likelihood you want to convert into a simplified likelihood. Simplify is able to read/write from/to stdin/stdout.

### In python script

You can also use `simplify` in a python script, e.g. to create some validation and cross-check plots and tables.

```py
import pyhf
import json

import simplify

pyhf.set_backend(pyhf.tensorlib, "minuit")
spec = json.load(open("likelihood.json", "r"))

ws = pyhf.Workspace(spec) # ws from full LH

# get model and data for each ws we just created
model = ws.model(modifier_settings = {"normsys": {"interpcode": "code4"},"histosys": {"interpcode": "code4p"},})
data = ws.data(model)

# run fit
fit_result = simplify.fitter.fit(ws)

plt = simplify.plot.pulls(
    fit_result,
    "plots/"
)

plt = simplify.plot.correlation_matrix(
    fit_result,
    "plots/",
    pruning_threshold=0.1
)

tables = simplify.plot.yieldsTable(
    ws,
    "plots/",
    fit_result,
)
```

## Dependencies

Naturally relies heavily on `pyhf`. Part of the code for plotting and validating results is inspired by Alexander Held's [`cabinetry`](https://github.com/alexander-held/cabinetry/).


