mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-16 15:20:24 +01:00
commit
63b2f4fd22
2 changed files with 20 additions and 6 deletions
|
@ -969,6 +969,8 @@ class Corr:
|
||||||
content_string += "Description: " + self.tag + "\n"
|
content_string += "Description: " + self.tag + "\n"
|
||||||
if self.N != 1:
|
if self.N != 1:
|
||||||
return content_string
|
return content_string
|
||||||
|
if isinstance(self[0], CObs):
|
||||||
|
return content_string
|
||||||
|
|
||||||
if print_range[1]:
|
if print_range[1]:
|
||||||
print_range[1] += 1
|
print_range[1] += 1
|
||||||
|
@ -1136,7 +1138,9 @@ class Corr:
|
||||||
for t in range(self.T):
|
for t in range(self.T):
|
||||||
if _check_for_none(self, newcontent[t]):
|
if _check_for_none(self, newcontent[t]):
|
||||||
continue
|
continue
|
||||||
if np.isnan(np.sum(newcontent[t]).value):
|
tmp_sum = np.sum(newcontent[t])
|
||||||
|
if hasattr(tmp_sum, "value"):
|
||||||
|
if np.isnan(tmp_sum.value):
|
||||||
newcontent[t] = None
|
newcontent[t] = None
|
||||||
if all([item is None for item in newcontent]):
|
if all([item is None for item in newcontent]):
|
||||||
raise Exception('Operation returns undefined correlator')
|
raise Exception('Operation returns undefined correlator')
|
||||||
|
@ -1194,8 +1198,8 @@ class Corr:
|
||||||
@property
|
@property
|
||||||
def real(self):
|
def real(self):
|
||||||
def return_real(obs_OR_cobs):
|
def return_real(obs_OR_cobs):
|
||||||
if isinstance(obs_OR_cobs, CObs):
|
if isinstance(obs_OR_cobs.flatten()[0], CObs):
|
||||||
return obs_OR_cobs.real
|
return np.vectorize(lambda x: x.real)(obs_OR_cobs)
|
||||||
else:
|
else:
|
||||||
return obs_OR_cobs
|
return obs_OR_cobs
|
||||||
|
|
||||||
|
@ -1204,8 +1208,8 @@ class Corr:
|
||||||
@property
|
@property
|
||||||
def imag(self):
|
def imag(self):
|
||||||
def return_imag(obs_OR_cobs):
|
def return_imag(obs_OR_cobs):
|
||||||
if isinstance(obs_OR_cobs, CObs):
|
if isinstance(obs_OR_cobs.flatten()[0], CObs):
|
||||||
return obs_OR_cobs.imag
|
return np.vectorize(lambda x: x.imag)(obs_OR_cobs)
|
||||||
else:
|
else:
|
||||||
return obs_OR_cobs * 0 # So it stays the right type
|
return obs_OR_cobs * 0 # So it stays the right type
|
||||||
|
|
||||||
|
|
|
@ -532,3 +532,13 @@ def test_prune():
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
corr_mat.prune(3)
|
corr_mat.prune(3)
|
||||||
corr_mat.prune(4)
|
corr_mat.prune(4)
|
||||||
|
|
||||||
|
|
||||||
|
def test_complex_Corr():
|
||||||
|
o1 = pe.pseudo_Obs(1.0, 0.1, "test")
|
||||||
|
cobs = pe.CObs(o1, -o1)
|
||||||
|
ccorr = pe.Corr([cobs, cobs, cobs])
|
||||||
|
assert np.all([ccorr.imag[i] == -ccorr.real[i] for i in range(ccorr.T)])
|
||||||
|
print(ccorr)
|
||||||
|
mcorr = pe.Corr(np.array([[ccorr, ccorr], [ccorr, ccorr]]))
|
||||||
|
assert np.all([mcorr.imag[i] == -mcorr.real[i] for i in range(mcorr.T)])
|
||||||
|
|
Loading…
Add table
Reference in a new issue