Skip to content

Commit

Permalink
Merge pull request #6 from HEPData/readme-usage-section
Browse files Browse the repository at this point in the history
Readme usage section
  • Loading branch information
Sinclert committed Nov 6, 2020
2 parents 3f6f675 + d28ef11 commit 24728e5
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,53 @@ submissions hold. Its evolution is coupled with the [hepdata-pyhf-visualizer][py
JS package, as this one renders what gets summarized by this component.


## Installation

Via pip:
```sh
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.
```python3
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:
```python3
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][black-web], in addition to [pre-commit][pre-commit-web] to control its style.

Expand All @@ -26,16 +73,14 @@ To check for style inconsistencies:
make check
```


## Testing
### Testing
The package uses [pytest][pytest-web] to run all the tests:

```sh
make test
```


## Release version
### Release version
To bump and tag a particular commit to mark a release:

```sh
Expand Down

0 comments on commit 24728e5

Please sign in to comment.