Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Adding test from readme
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Oct 24, 2018
1 parent daee99d commit 8e86c15
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from numpythia import Pythia, hepmc_write, hepmc_read
from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID
from numpythia.testcmnd import get_cmnd
from numpy.testing import assert_array_equal

def test_first_example():
pythia = Pythia(get_cmnd('w'), random_state=1)

selection = ((STATUS == 1) & ~HAS_END_VERTEX &
(ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))

# generate events while writing to ascii hepmc
for event in hepmc_write('events.hepmc', pythia(events=1)):
array1 = event.all(selection)

# read the same event back from ascii hepmc
for event in hepmc_read('events.hepmc'):
array2 = event.all(selection)

assert_array_equal(array1, array2)

0 comments on commit 8e86c15

Please sign in to comment.