Skip to content

Commit

Permalink
fix: dict classes should produce instances of themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky authored and matthewfeickert committed Mar 20, 2024
1 parent aefb63b commit 01b37d0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pylhe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,25 @@ class LHEInit(dict):
"numProcesses",
]

def __init__(self):
pass
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)

@classmethod
def fromstring(cls, string):
return dict(zip(cls.fieldnames, map(float, string.split())))
return cls(**dict(zip(cls.fieldnames, map(float, string.split()))))


class LHEProcInfo(dict):
"""Store the process info block as dict."""

fieldnames = ["xSection", "error", "unitWeight", "procId"]

def __init__(self):
pass
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)

@classmethod
def fromstring(cls, string):
return dict(zip(cls.fieldnames, map(float, string.split())))
return cls(**dict(zip(cls.fieldnames, map(float, string.split()))))


def _extract_fileobj(filepath):
Expand Down

0 comments on commit 01b37d0

Please sign in to comment.