mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
Merge branch 'develop' into documentation
This commit is contained in:
commit
4317187392
5 changed files with 30 additions and 15 deletions
|
@ -190,7 +190,7 @@
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[7.2(1.7) -1.00(45)]\n"
|
"[7.2(1.7) -1.00(46)]\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -243,7 +243,7 @@
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[[2.025(49) 0.0]\n",
|
"[[2.025(49) 0.0]\n",
|
||||||
" [-0.494(50) 0.870(29)]]\n"
|
" [-0.494(51) 0.870(29)]]\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -296,7 +296,7 @@
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[[0.494(12) 0.0]\n",
|
"[[0.494(12) 0.0]\n",
|
||||||
" [0.280(40) 1.150(38)]]\n",
|
" [0.280(40) 1.150(39)]]\n",
|
||||||
"Check:\n",
|
"Check:\n",
|
||||||
"[[1.0 0.0]\n",
|
"[[1.0 0.0]\n",
|
||||||
" [0.0 1.0]]\n"
|
" [0.0 1.0]]\n"
|
||||||
|
@ -330,10 +330,10 @@
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Eigenvalues:\n",
|
"Eigenvalues:\n",
|
||||||
"[0.705(56) 4.39(20)]\n",
|
"[0.705(57) 4.39(19)]\n",
|
||||||
"Eigenvectors:\n",
|
"Eigenvectors:\n",
|
||||||
"[[-0.283(26) -0.9592(75)]\n",
|
"[[-0.283(26) -0.9592(76)]\n",
|
||||||
" [-0.9592(75) 0.283(26)]]\n"
|
" [-0.9592(76) 0.283(26)]]\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -363,17 +363,13 @@
|
||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Check eigenvector 1\n",
|
"[[ True True]\n",
|
||||||
"[-5.551115123125783e-17 0.0]\n",
|
" [ True True]]\n"
|
||||||
"Check eigenvector 2\n",
|
|
||||||
"[0.0 -2.220446049250313e-16]\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"for i in range(2):\n",
|
"print(matrix @ v == e * v)"
|
||||||
" print('Check eigenvector', i + 1)\n",
|
|
||||||
" print(matrix @ v[:, i] - v[:, i] * e[i])"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ class Corr:
|
||||||
newcontent.append(self.content[t] + y.content[t])
|
newcontent.append(self.content[t] + y.content[t])
|
||||||
return Corr(newcontent)
|
return Corr(newcontent)
|
||||||
|
|
||||||
elif isinstance(y, (Obs, int, float, CObs)):
|
elif isinstance(y, (Obs, int, float, CObs, complex)):
|
||||||
newcontent = []
|
newcontent = []
|
||||||
for t in range(self.T):
|
for t in range(self.T):
|
||||||
if _check_for_none(self, self.content[t]):
|
if _check_for_none(self, self.content[t]):
|
||||||
|
@ -1103,7 +1103,7 @@ class Corr:
|
||||||
newcontent.append(self.content[t] * y.content[t])
|
newcontent.append(self.content[t] * y.content[t])
|
||||||
return Corr(newcontent)
|
return Corr(newcontent)
|
||||||
|
|
||||||
elif isinstance(y, (Obs, int, float, CObs)):
|
elif isinstance(y, (Obs, int, float, CObs, complex)):
|
||||||
newcontent = []
|
newcontent = []
|
||||||
for t in range(self.T):
|
for t in range(self.T):
|
||||||
if _check_for_none(self, self.content[t]):
|
if _check_for_none(self, self.content[t]):
|
||||||
|
|
|
@ -784,6 +784,8 @@ class Obs:
|
||||||
else:
|
else:
|
||||||
if isinstance(y, np.ndarray):
|
if isinstance(y, np.ndarray):
|
||||||
return np.array([self + o for o in y])
|
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']:
|
elif y.__class__.__name__ in ['Corr', 'CObs']:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -749,3 +749,13 @@ def test_corr_item():
|
||||||
corr_mat = pe.Corr(np.array([[corr_aa, corr_ab], [corr_ab, corr_aa]]))
|
corr_mat = pe.Corr(np.array([[corr_aa, corr_ab], [corr_ab, corr_aa]]))
|
||||||
corr_mat.item(0, 0)
|
corr_mat.item(0, 0)
|
||||||
assert corr_mat[0].item(0, 1) == corr_mat.item(0, 1)[0]
|
assert corr_mat[0].item(0, 1) == corr_mat.item(0, 1)[0]
|
||||||
|
|
||||||
|
|
||||||
|
def test_complex_add_and_mul():
|
||||||
|
o = pe.pseudo_Obs(1.0, 0.3, "my_r345sfg16£$%&$%^%$^$", samples=47)
|
||||||
|
co = pe.CObs(o, 0.341 * o)
|
||||||
|
for obs in [o, co]:
|
||||||
|
cc = pe.Corr([obs for _ in range(4)])
|
||||||
|
cc += 2j
|
||||||
|
cc = cc * 4j
|
||||||
|
cc.real + cc.imag
|
||||||
|
|
|
@ -1333,3 +1333,10 @@ def test_vec_gm():
|
||||||
cc = pe.Corr(obs)
|
cc = pe.Corr(obs)
|
||||||
pe.gm(cc, S=4.12)
|
pe.gm(cc, S=4.12)
|
||||||
assert np.all(np.vectorize(lambda x: x.S["qq"])(cc.content) == 4.12)
|
assert np.all(np.vectorize(lambda x: x.S["qq"])(cc.content) == 4.12)
|
||||||
|
|
||||||
|
def test_complex_addition():
|
||||||
|
o = pe.pseudo_Obs(34.12, 1e-4, "testens")
|
||||||
|
r = o + 2j
|
||||||
|
assert r.real == o
|
||||||
|
r = r * 1j
|
||||||
|
assert r.imag == o
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue