Skip to content

Commit

Permalink
Add powheg lhe tests
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Dec 21, 2023
1 parent 3ca4ef0 commit 1803673
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"pytest~=6.0",
"pytest-cov>=2.5.1",
"scikit-hep-testdata>=0.4.0",
"scikit-hep-testdata>=0.4.36",
"pydocstyle",
}
)
Expand Down
56 changes: 56 additions & 0 deletions tests/test_lhe_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

TEST_FILE_LHE_v1 = skhep_testdata.data_path("pylhe-testfile-pr29.lhe")
TEST_FILE_LHE_v3 = skhep_testdata.data_path("pylhe-testlhef3.lhe")
TEST_FILE_LHE_INITRWGT_WEIGHTS = skhep_testdata.data_path("pylhe-testfile-powheg-box-v2-hvq.lhe")
TEST_FILE_LHE_RWGT_WGT= skhep_testdata.data_path("pylhe-testfile-powheg-box-v2-W.lhe")
TEST_FILES_LHE_POWHEG = [skhep_testdata.data_path("pylhe-testfile-powheg-box-v2-%s.lhe"%(proc)) for proc in ["Z", "W", "Zj", "trijet","directphoton", "hvq"]]


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -135,6 +138,59 @@ def test_read_lhe_with_attributes_v3():
assert isinstance(e, LHEEvent)


@pytest.mark.parametrize('file', TEST_FILES_LHE_POWHEG)
def test_read_lhe_powheg(file):
"""
Test method read_lhe() on a LesHouchesEvents POWHEG file.
"""
events = pylhe.read_lhe(file)

assert events
for e in events:
assert isinstance(e, LHEEvent)

@pytest.mark.parametrize('file', TEST_FILES_LHE_POWHEG)
def test_read_lhe_with_attributes_powheg(file):
"""
Test method read_lhe_with_attributes() on a LesHouchesEvents POWHEG file.
"""
events = pylhe.read_lhe_with_attributes(file)

assert events
for e in events:
assert isinstance(e, LHEEvent)

@pytest.mark.parametrize('file', TEST_FILES_LHE_POWHEG)
def test_read_lhe_powheg(file):
"""
Test method read_lhe() on a LesHouchesEvents POWHEG file.
"""
events = pylhe.read_lhe(file)

assert events
for e in events:
assert isinstance(e, LHEEvent)

def test_read_lhe_initrwgt_weights_v3():
"""
"""
events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_INITRWGT_WEIGHTS)

assert events
for e in events:
assert isinstance(e, LHEEvent)
assert len(e.weights) > 0

def test_read_lhe_rwgt_wgt_v3():
"""
"""
events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_RWGT_WGT)

assert events
for e in events:
assert isinstance(e, LHEEvent)
assert len(e.weights) > 0

def test_issue_102():
"""
Test a file containing lines starting with "#aMCatNLO".
Expand Down

0 comments on commit 1803673

Please sign in to comment.