mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
feat: added support for addition and multiplication of complex numbers (#209)
to Corr objects.
This commit is contained in:
parent
01ef97ffdf
commit
7f8c2ce33b
4 changed files with 21 additions and 2 deletions
|
@ -1075,7 +1075,7 @@ class Corr:
|
|||
newcontent.append(self.content[t] + y.content[t])
|
||||
return Corr(newcontent)
|
||||
|
||||
elif isinstance(y, (Obs, int, float, CObs)):
|
||||
elif isinstance(y, (Obs, int, float, CObs, complex)):
|
||||
newcontent = []
|
||||
for t in range(self.T):
|
||||
if _check_for_none(self, self.content[t]):
|
||||
|
@ -1103,7 +1103,7 @@ class Corr:
|
|||
newcontent.append(self.content[t] * y.content[t])
|
||||
return Corr(newcontent)
|
||||
|
||||
elif isinstance(y, (Obs, int, float, CObs)):
|
||||
elif isinstance(y, (Obs, int, float, CObs, complex)):
|
||||
newcontent = []
|
||||
for t in range(self.T):
|
||||
if _check_for_none(self, self.content[t]):
|
||||
|
|
|
@ -784,6 +784,8 @@ class Obs:
|
|||
else:
|
||||
if isinstance(y, np.ndarray):
|
||||
return np.array([self + o for o in y])
|
||||
elif isinstance(y, complex):
|
||||
return CObs(self, 0) + y
|
||||
elif y.__class__.__name__ in ['Corr', 'CObs']:
|
||||
return NotImplemented
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue