From 2b30623235d21a55b9461a1fc058ca45a20440c8 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 11 Oct 2021 09:40:20 +0100 Subject: [PATCH] comments extended --- pyerrors/correlators.py | 50 +++++++++++++---------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 9a332c6c..b045017a 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -58,9 +58,9 @@ class Corr: self.T = len(self.content) #for convenience: will be used a lot - #The attribute "range" [start,end] marks a range of two timeslices. + #The attribute "range" [start,end] marks a range of two timeslices. #This is useful for keeping track of plateaus and fitranges. - #The range can be inherited from other Corrs, if the operation should not alter a chosen range eg. multiplication with a constant. + #The range can be inherited from other Corrs, if the operation should not alter a chosen range eg. multiplication with a constant. if not prange is None: self.prange=prange @@ -143,8 +143,8 @@ class Corr: newcontent.append(0.5 * (self.content[t] + self.content[self.T - t])) if(all([x is None for x in newcontent])): raise Exception("Corr could not be symmetrized: No redundant values") - - return Corr(newcontent,prange= self.prange if hasattr(self,"prange") else None) + + return Corr(newcontent, prange=self.prange if hasattr(self,"prange") else None) def anti_symmetric(self): @@ -192,12 +192,12 @@ class Corr: G0=G.content[t0] L = mat_mat_op(anp.linalg.cholesky, G0) Li = mat_mat_op(anp.linalg.inv, L) - LT=L.T + LT=L.T LTi=mat_mat_op(anp.linalg.inv, LT) newcontent=[] for t in range(self.T): Gt=G.content[t] - M=Li@Gt@LTi + M=Li@Gt@LTi eigenvalues = eigh(M)[0] #print(eigenvalues) eigenvalue=eigenvalues[-state] @@ -205,14 +205,6 @@ class Corr: return Corr(newcontent) - - - - - - - - def roll(self, dt): return Corr(list(np.roll(np.array(self.content, dtype=object), dt))) @@ -307,7 +299,7 @@ class Corr: raise Exception("Correlator must be projected before fitting") #The default behaviour is: - #1 use explicit fitrange + #1 use explicit fitrange # if none is provided, use the range of the corr # if this is also not set, use the whole length of the corr (This could come with a warning!) @@ -316,7 +308,7 @@ class Corr: if hasattr(self,"prange"): fitrange=self.prange else: - fitrange=[0, self.T] + fitrange=[0, self.T] xs = [x for x in range(fitrange[0], fitrange[1]) if not self.content[x] is None] ys = [self.content[x][0] for x in range(fitrange[0], fitrange[1]) if not self.content[x] is None] @@ -333,8 +325,8 @@ class Corr: def plateau(self, plateau_range=None, method="fit"): if not plateau_range: if hasattr(self,"prange"): - plateau_range=self.prange - else: + plateau_range=self.prange + else: raise Exception("no plateau range provided") if self.N != 1: raise Exception("Correlator must be projected before getting a plateau.") @@ -350,11 +342,11 @@ class Corr: return returnvalue else: - raise Exception("Unsupported plateau method: " + method) + raise Exception("Unsupported plateau method: " + method) - def set_prange(self,prange): + def set_prange(self,prange): if not len(prange)==2: raise Exception("range must be a list or array with two values") if not ((isinstance(prange[0],int)) and (isinstance(prange[1],int))): @@ -362,18 +354,10 @@ class Corr: if not (0<=prange[0]<=self.T and 0<=prange[1]<=self.T and prange[0]