Skip to content

Commit

Permalink
[doc] README - add a get started
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardo-rodrigues committed Jun 8, 2022
1 parent 555f5d9 commit 23a97f8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,39 @@ python -m pip install pylhe[viz]

The visualization capabilities require external dependencies of [Graphviz](https://graphviz.org/) and LaTeX.

## Get started

The example below provides a quick get-started. Full functionality can be inspected
from the functions provided in the `pylhe` module.

```python
import itertools
import pylhe

# You can use LHE files from our scikit-hep-testdata package
from skhep_testdata import data_path

lhe_file = data_path("pylhe-testlhef3.lhe")

events = pylhe.read_lhe_with_attributes(lhe_file)

print(f"Number of events: {pylhe.read_num_events(lhe_file)}")

# Get hold of event 1
event = next(itertools.islice(events, 1, 2))

# A DOT language graph of the event can be inspected as follows:
print(event.graph.source)

# The graph is nicely displayed as SVG in notebooks:
event

# If not in a notebook, or wishing to save the DOT graph under one of the available formats,
# do for example (refer to the Graphviz documentation for more)
event.graph.render(filename="test", format="png", cleanup=True)
event.graph.render(filename="test", format="pdf", cleanup=True)
```

## Citation

The preferred BibTeX entry for citation of `pylhe` is
Expand Down

0 comments on commit 23a97f8

Please sign in to comment.