From d79aa2cf74609f7b9f4d1330e510729b762134a0 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 15 Jun 2022 14:01:26 +0100 Subject: [PATCH 1/3] refactor: range in Corr.print and __repr__ renamed to print_range --- pyerrors/correlators.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 921ae732..646ef875 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -897,10 +897,10 @@ class Corr: else: raise Exception("Unknown datatype " + str(datatype)) - def print(self, range=[0, None]): - print(self.__repr__(range)) + def print(self, print_range=[0, None]): + print(self.__repr__(print_range)) - def __repr__(self, range=[0, None]): + def __repr__(self, print_range=[0, None]): content_string = "" content_string += "Corr T=" + str(self.T) + " N=" + str(self.N) + "\n" # +" filled with"+ str(type(self.content[0][0])) there should be a good solution here @@ -910,14 +910,14 @@ class Corr: if self.N != 1: return content_string - if range[1]: - range[1] += 1 + if print_range[1]: + print_range[1] += 1 content_string += 'x0/a\tCorr(x0/a)\n------------------\n' - for i, sub_corr in enumerate(self.content[range[0]:range[1]]): + for i, sub_corr in enumerate(self.content[print_range[0]:print_range[1]]): if sub_corr is None: - content_string += str(i + range[0]) + '\n' + content_string += str(i + print_range[0]) + '\n' else: - content_string += str(i + range[0]) + content_string += str(i + print_range[0]) for element in sub_corr: content_string += '\t' + ' ' * int(element >= 0) + str(element) content_string += '\n' From 02403fc282410e8caa02276e2e4045219dff7421 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 15 Jun 2022 14:04:07 +0100 Subject: [PATCH 2/3] fix: Modification of parameter with default in input.dobs fixed. --- pyerrors/input/dobs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyerrors/input/dobs.py b/pyerrors/input/dobs.py index 498e88d8..92ae3e35 100644 --- a/pyerrors/input/dobs.py +++ b/pyerrors/input/dobs.py @@ -652,7 +652,7 @@ def _dobsdict_to_xmlstring_spaces(d, space=' '): return o -def create_dobs_string(obsl, name, spec='dobs v1.0', origin='', symbol=[], who=None, enstags={}): +def create_dobs_string(obsl, name, spec='dobs v1.0', origin='', symbol=[], who=None, enstags=None): """Generate the string for the export of a list of Obs or structures containing Obs to a .xml.gz file according to the Zeuthen dobs format. @@ -678,6 +678,8 @@ def create_dobs_string(obsl, name, spec='dobs v1.0', origin='', symbol=[], who=N Provide alternative enstag for ensembles in the form enstags = {ename: enstag} Otherwise, the ensemble name is used. """ + if enstags is None: + enstags = {} od = {} r_names = [] for o in obsl: From abdeace107f8c68003b4ff71148d0d87cfd24009 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 15 Jun 2022 14:05:41 +0100 Subject: [PATCH 3/3] fix: Modification of parameter with default in Corr.__repr__ fixed. --- pyerrors/correlators.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 646ef875..ecb8d525 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -897,12 +897,14 @@ class Corr: else: raise Exception("Unknown datatype " + str(datatype)) - def print(self, print_range=[0, None]): + def print(self, print_range=None): print(self.__repr__(print_range)) - def __repr__(self, print_range=[0, None]): - content_string = "" + def __repr__(self, print_range=None): + if print_range is None: + print_range = [0, None] + content_string = "" content_string += "Corr T=" + str(self.T) + " N=" + str(self.N) + "\n" # +" filled with"+ str(type(self.content[0][0])) there should be a good solution here if self.tag is not None: