mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 20:13:41 +02:00
feat: basic arithmetic operations for correlators and np.ndarrays of the
same length work now.
This commit is contained in:
parent
1ee4aa0a59
commit
dd3bee5635
2 changed files with 38 additions and 7 deletions
|
@ -867,6 +867,11 @@ class Corr:
|
|||
else:
|
||||
newcontent.append(self.content[t] + y)
|
||||
return Corr(newcontent, prange=self.prange)
|
||||
elif isinstance(y, np.ndarray):
|
||||
if y.shape == (self.T,):
|
||||
return Corr(list((np.array(self.content).T + y).T))
|
||||
else:
|
||||
raise ValueError("operands could not be broadcast together")
|
||||
else:
|
||||
raise TypeError("Corr + wrong type")
|
||||
|
||||
|
@ -890,6 +895,11 @@ class Corr:
|
|||
else:
|
||||
newcontent.append(self.content[t] * y)
|
||||
return Corr(newcontent, prange=self.prange)
|
||||
elif isinstance(y, np.ndarray):
|
||||
if y.shape == (self.T,):
|
||||
return Corr(list((np.array(self.content).T * y).T))
|
||||
else:
|
||||
raise ValueError("operands could not be broadcast together")
|
||||
else:
|
||||
raise TypeError("Corr * wrong type")
|
||||
|
||||
|
@ -939,6 +949,11 @@ class Corr:
|
|||
else:
|
||||
newcontent.append(self.content[t] / y)
|
||||
return Corr(newcontent, prange=self.prange)
|
||||
elif isinstance(y, np.ndarray):
|
||||
if y.shape == (self.T,):
|
||||
return Corr(list((np.array(self.content).T / y).T))
|
||||
else:
|
||||
raise ValueError("operands could not be broadcast together")
|
||||
else:
|
||||
raise TypeError('Corr / wrong type')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue