Skip to content

HEPData/hepdata-pyhf-extractor

Repository files navigation

HEPData pyhf extractor

GH Actions status Coverage status Project license

Python package to extract and summarize information from the pyhf submissions.

About

This package aims to define the post-submission computations to summarize the information that pyhf submissions hold. Its evolution is coupled with the hepdata-pyhf-visualizer JS package, as this one renders what gets summarized by this component.

Installation

Via pip:

pip install hepdata-pyhf-extractor

Via GitHub (for developers):

git clone https://github.com/HEPData/hepdata-pyhf-extractor
cd hepdata-pyhf-extractor
pip install ".[dev]"

Usage

To extract basic information out of a pyhf Pallet file, the summarizers can:

A) Receive a Pallet file path for them to open and read it internally.

from pyhf_extractor import V1PalletSummarizer

# The provided file can be either .json.gz or .json
pallet_path = "example_pallet.json.gz"
pallet_path = "example_pallet.json"

summarizer = V1PalletSummarizer(pallet_path=pallet_path)
summary = summarizer.summarize()

B) Receive an already parsed Pallet file:

import gzip
import json
from pyhf_extractor import V1PalletSummarizer

pallet_path = "example_pallet.json.gz"

with gzip.open(pallet_path) as file:
    pallet_data = json.load(file)           

summarizer = V1PalletSummarizer(pallet_data=pallet_data)
summary = summarizer.summarize()

Development

The package uses Black, in addition to pre-commit to control its style.

To install the pre-commit hook:

pre-commit install

To check for style inconsistencies:

make check

Testing

The package uses pytest to run all the tests:

make test

Release version

To bump and tag a particular commit to mark a release:

# Any of the following options
make tag-major
make tag-minor
make tag-patch

About

Package to summarize pyhf submissions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published