mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 23:00:25 +01:00
added attribute sigma to zero within error, npr module improved
This commit is contained in:
parent
f95123bd18
commit
e45f330e9d
2 changed files with 14 additions and 10 deletions
|
@ -1,23 +1,23 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
gamma = [0, 0, 0, 0]
|
gammaX = np.array(
|
||||||
gamma[0] = np.array(
|
|
||||||
[[0, 0, 0, 1j], [0, 0, 1j, 0], [0, -1j, 0, 0], [-1j, 0, 0, 0]],
|
[[0, 0, 0, 1j], [0, 0, 1j, 0], [0, -1j, 0, 0], [-1j, 0, 0, 0]],
|
||||||
dtype=complex)
|
dtype=complex)
|
||||||
gamma[1] = np.array(
|
gammaY = np.array(
|
||||||
[[0, 0, 0, -1], [0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0]],
|
[[0, 0, 0, -1], [0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0]],
|
||||||
dtype=complex)
|
dtype=complex)
|
||||||
gamma[2] = np.array(
|
gammaZ = np.array(
|
||||||
[[0, 0, 1j, 0], [0, 0, 0, -1j], [-1j, 0, 0, 0], [0, 1j, 0, 0]],
|
[[0, 0, 1j, 0], [0, 0, 0, -1j], [-1j, 0, 0, 0], [0, 1j, 0, 0]],
|
||||||
dtype=complex)
|
dtype=complex)
|
||||||
gamma[3] = np.array(
|
gammaT = np.array(
|
||||||
[[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]],
|
[[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]],
|
||||||
dtype=complex)
|
dtype=complex)
|
||||||
|
gamma = np.array([gammaX, gammaY, gammaZ, gammaT])
|
||||||
gamma5 = np.array(
|
gamma5 = np.array(
|
||||||
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]],
|
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]],
|
||||||
dtype=complex)
|
dtype=complex)
|
||||||
imat = np.array(
|
identity = np.array(
|
||||||
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
|
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
|
||||||
dtype=complex)
|
dtype=complex)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ imat = np.array(
|
||||||
def Grid_gamma(gamma_tag):
|
def Grid_gamma(gamma_tag):
|
||||||
"""Returns gamma matrix in Grid labeling."""
|
"""Returns gamma matrix in Grid labeling."""
|
||||||
if gamma_tag == 'Identity':
|
if gamma_tag == 'Identity':
|
||||||
g = imat
|
g = identity
|
||||||
elif gamma_tag == 'Gamma5':
|
elif gamma_tag == 'Gamma5':
|
||||||
g = gamma5
|
g = gamma5
|
||||||
elif gamma_tag == 'GammaX':
|
elif gamma_tag == 'GammaX':
|
||||||
|
@ -87,7 +87,7 @@ class Npr_matrix(np.ndarray):
|
||||||
def _propagate_mom(self, other, name):
|
def _propagate_mom(self, other, name):
|
||||||
s_mom = getattr(self, name, None)
|
s_mom = getattr(self, name, None)
|
||||||
o_mom = getattr(other, name, None)
|
o_mom = getattr(other, name, None)
|
||||||
if s_mom and o_mom:
|
if s_mom is not None and o_mom is not None:
|
||||||
if not np.allclose(s_mom, o_mom):
|
if not np.allclose(s_mom, o_mom):
|
||||||
raise Exception(name + ' does not match.')
|
raise Exception(name + ' does not match.')
|
||||||
return o_mom if o_mom else s_mom
|
return o_mom if o_mom else s_mom
|
||||||
|
|
|
@ -337,8 +337,12 @@ class Obs:
|
||||||
for e_name in self.e_names:
|
for e_name in self.e_names:
|
||||||
print(e_name, ':', self.e_content[e_name])
|
print(e_name, ':', self.e_content[e_name])
|
||||||
|
|
||||||
def is_zero_within_error(self):
|
def is_zero_within_error(self, sigma=1):
|
||||||
return np.abs(self.value) <= self.dvalue
|
""" Checks whether the observable is zero within 'sigma' standard errors.
|
||||||
|
|
||||||
|
Works only properly when the gamma method was run.
|
||||||
|
"""
|
||||||
|
return np.abs(self.value) <= sigma * self.dvalue
|
||||||
|
|
||||||
def is_zero(self):
|
def is_zero(self):
|
||||||
return np.isclose(0.0, self.value) and all(np.allclose(0.0, delta) for delta in self.deltas.values())
|
return np.isclose(0.0, self.value) and all(np.allclose(0.0, delta) for delta in self.deltas.values())
|
||||||
|
|
Loading…
Add table
Reference in a new issue