From 23c5e53f69e9af573712dfdbd26e9b0fa6b7a16c Mon Sep 17 00:00:00 2001 From: RoyStegeman Date: Fri, 17 May 2024 18:17:47 +0100 Subject: [PATCH] Passes variant info to TupleComp for DataSetInput also removes parenthesis from @lru_cache, see: https://bugs.python.org/issue36772 --- validphys2/src/validphys/core.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/validphys2/src/validphys/core.py b/validphys2/src/validphys/core.py index 1056443362..1825fd18cc 100644 --- a/validphys2/src/validphys/core.py +++ b/validphys2/src/validphys/core.py @@ -47,7 +47,7 @@ def __hash__(self): def __repr__(self): argvals = ', '.join('%s=%r' % vals for vals in zip(self.argnames(), self.comp_tuple)) - return '{}({})'.format(self.__class__.__qualname__, argvals) + return f'{self.__class__.__qualname__}({argvals})' class PDFDoesNotExist(Exception): @@ -344,7 +344,7 @@ def __init__(self, *, name, sys, cfac, frac, weight, custom_group, variant): self.weight = weight self.custom_group = custom_group self.variant = variant - super().__init__(name, sys, cfac, frac, weight, custom_group) + super().__init__(name, sys, cfac, frac, weight, custom_group, variant) def __str__(self): return self.name @@ -428,7 +428,7 @@ def __init__(self, inputs, threshold): self.threshold = threshold super().__init__(self.inputs, self.threshold) - @functools.lru_cache() + @functools.lru_cache def load(self): # TODO: Update this when a suitable interace becomes available from validphys.convolution import central_predictions @@ -487,7 +487,7 @@ def __init__(self, *, name, commondata, fkspecs, thspec, cuts, frac=1, op=None, super().__init__(name, commondata, fkspecs, thspec, cuts, frac, op, weight) - @functools.lru_cache() + @functools.lru_cache def load_commondata(self): """Strips the commondata loading from `load`""" cd = self.commondata.load() @@ -562,7 +562,7 @@ def load_cfactors(self): return [[parse_cfactor(c.open("rb")) for c in cfacs] for cfacs in self.cfactors] - @functools.lru_cache() + @functools.lru_cache def load_with_cuts(self, cuts): """Load the fktable and apply cuts immediately. Returns a FKTableData""" return load_fktable(self).with_cuts(cuts) @@ -586,7 +586,7 @@ def to_unweighted(self): ) return self - @functools.lru_cache() + @functools.lru_cache def load_commondata(self): return self.commondata.load() @@ -669,7 +669,7 @@ def __iter__(self): yield self.name yield self.path - @functools.lru_cache() + @functools.lru_cache def as_input(self): p = self.path / 'filter.yml' log.debug('Reading input from fit configuration %s', p) @@ -930,4 +930,4 @@ def as_pair(self): return self.label, self.indexes def __str__(self): - return '{}: {}'.format(self.label, self.indexes) + return f'{self.label}: {self.indexes}'