Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Feb 20, 2024
1 parent d0581df commit 93145d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/pylhe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ def tolhe(self):

# custom backwards compatibility get for dict
def __getitem__(self, key):
if not key in self:
if key not in self:
return self["initInfo"][key]
else:
return super().__getitem__(key)

# custom backwards compatibility set for dict
def __setitem__(self, key, value):
if not key in self:
if key not in self:
self["initInfo"][key] = value
else:
self.super().__setitem__(key, value)
Expand Down Expand Up @@ -509,7 +509,7 @@ def write_lhe_string(lheinit, lheevents):
s += lheinit.tolhe() + "\n"
for e in lheevents:
s += e.tolhe() + "\n"
s += f"</LesHouchesEvents>"
s += "</LesHouchesEvents>"
return s


Expand Down
46 changes: 15 additions & 31 deletions tests/test_lhe_writer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import gzip
import os
import shutil
from pathlib import Path
from tempfile import NamedTemporaryFile

import pytest
import skhep_testdata

import pylhe
from pylhe import LHEEvent

TEST_FILE_LHE_v1 = skhep_testdata.data_path("pylhe-testfile-pr29.lhe")
TEST_FILE_LHE_v3 = skhep_testdata.data_path("pylhe-testlhef3.lhe")
Expand All @@ -23,38 +15,36 @@


def test_write_lhe_eventline():
""" """
"""
Test that the event line is written correctly.
"""
events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_v3)

assert events
for e in events:
assert (
e = next(events)
assert (
e.particles[0].tolhe()
== " 5 -1 0 0 501 0 0.00000000e+00 0.00000000e+00 1.43229060e+02 1.43309460e+02 4.80000000e+00 0.0000e+00 0.0000e+00"
)
break


def test_write_lhe_eventinfo():
""" """
"""
Test that the event info is written correctly.
"""
events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_v3)

assert events
for e in events:
assert (
e = next(events)
assert (
e.eventinfo.tolhe()
== " 5 66 5.0109093000e+01 1.4137688000e+02 7.5563862000e-03 1.2114027000e-01"
)
break


def test_write_lhe_event():
""" """
"""
Test that the event is written correctly.
"""
events = pylhe.read_lhe_with_attributes(TEST_FILE_LHE_v3)

assert events
for e in events:
assert (
e = next(events)
assert (
e.tolhe()
== """<event>
5 66 5.0109093000e+01 1.4137688000e+02 7.5563862000e-03 1.2114027000e-01
Expand All @@ -76,7 +66,6 @@ def test_write_lhe_event():
</rwgt>
</event>"""
)
break


def test_write_lhe_init():
Expand All @@ -90,7 +79,6 @@ def test_write_lhe_init():
init["procInfo"][0].tolhe()
== " 5.0109086e+01 8.9185414e-02 5.0109093e+01 66"
)
print(init["weightgroup"])

assert (
init.tolhe()
Expand Down Expand Up @@ -161,7 +149,3 @@ def test_write_lhe_init():
</event>
</LesHouchesEvents>"""
)


def test_write_read_lhe_identical():
pass

0 comments on commit 93145d7

Please sign in to comment.