From bb57fe2da0e00cb79e5c014409d3798a78c094f5 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 22 Feb 2024 17:15:46 +0100 Subject: [PATCH] more suggestions from code review --- validphys2/src/validphys/commondataparser.py | 7 +++++-- validphys2/src/validphys/coredata.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/validphys2/src/validphys/commondataparser.py b/validphys2/src/validphys/commondataparser.py index 9eb5f26365..b1851d6dd4 100644 --- a/validphys2/src/validphys/commondataparser.py +++ b/validphys2/src/validphys/commondataparser.py @@ -143,6 +143,8 @@ def _get_ported_kinlabel(process_type): # special case in which the process in DIS- or DYP-like if process_type[:3] in ("DIS", "DYP"): return _get_ported_kinlabel(process_type[:3]) + if len(process_type.split("_")) > 1: + return _get_process_description(process_type.rsplit("_", 1)[0]) raise KeyError(f"Label {process_type} not recognized in KINLABEL_LATEX") @@ -407,11 +409,12 @@ def __post_init__(self): unused = list(set(self.kinematics.variables) - set(self.kinematic_coverage)) diff_to_3 = 3 - len(self.kinematic_coverage) if unused: - self.kinematic_coverage += unused[diff_to_3:] + nkincov = self.kinematic_coverage + unused[diff_to_3:] else: - self.kinematic_coverage += [f"extra_{i}" for i in range(diff_to_3)] + nkincov = self.kinematic_coverage + [f"extra_{i}" for i in range(diff_to_3)] object.__setattr__(self, 'process_type', self.process_type.upper()) + object.__setattr__(self, 'kinematic_coverage', nkincov) def __hash__(self): """ObservableMetaData is defined by: diff --git a/validphys2/src/validphys/coredata.py b/validphys2/src/validphys/coredata.py index 8a9c7a8c81..d2f3a7dadc 100644 --- a/validphys2/src/validphys/coredata.py +++ b/validphys2/src/validphys/coredata.py @@ -253,8 +253,8 @@ class CommonData: nsys: int commondata_table: pd.DataFrame = dataclasses.field(repr=False) systype_table: pd.DataFrame = dataclasses.field(repr=False) - systematics_table: pd.DataFrame = dataclasses.field(init=None, repr=False) legacy: bool + systematics_table: Optional[pd.DataFrame] = dataclasses.field(init=None, repr=False) legacy_name: Optional[str] = None kin_variables: Optional[list] = None