From 01b37d0248f89286237c493a1eaab1660b309df5 Mon Sep 17 00:00:00 2001 From: Alexander Puck Neuwirth Date: Tue, 20 Feb 2024 16:17:34 +0100 Subject: [PATCH] fix: dict classes should produce instances of themselves --- src/pylhe/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pylhe/__init__.py b/src/pylhe/__init__.py index 657f6239..d59b7a79 100644 --- a/src/pylhe/__init__.py +++ b/src/pylhe/__init__.py @@ -185,12 +185,12 @@ 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): @@ -198,12 +198,12 @@ class LHEProcInfo(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):