mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +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
|
||||
|
||||
|
||||
gamma = [0, 0, 0, 0]
|
||||
gamma[0] = np.array(
|
||||
gammaX = np.array(
|
||||
[[0, 0, 0, 1j], [0, 0, 1j, 0], [0, -1j, 0, 0], [-1j, 0, 0, 0]],
|
||||
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]],
|
||||
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]],
|
||||
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]],
|
||||
dtype=complex)
|
||||
gamma = np.array([gammaX, gammaY, gammaZ, gammaT])
|
||||
gamma5 = np.array(
|
||||
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]],
|
||||
dtype=complex)
|
||||
imat = np.array(
|
||||
identity = np.array(
|
||||
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
|
||||
dtype=complex)
|
||||
|
||||
|
@ -25,7 +25,7 @@ imat = np.array(
|
|||
def Grid_gamma(gamma_tag):
|
||||
"""Returns gamma matrix in Grid labeling."""
|
||||
if gamma_tag == 'Identity':
|
||||
g = imat
|
||||
g = identity
|
||||
elif gamma_tag == 'Gamma5':
|
||||
g = gamma5
|
||||
elif gamma_tag == 'GammaX':
|
||||
|
@ -87,7 +87,7 @@ class Npr_matrix(np.ndarray):
|
|||
def _propagate_mom(self, other, name):
|
||||
s_mom = getattr(self, 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):
|
||||
raise Exception(name + ' does not match.')
|
||||
return o_mom if o_mom else s_mom
|
||||
|
|
|
@ -337,8 +337,12 @@ class Obs:
|
|||
for e_name in self.e_names:
|
||||
print(e_name, ':', self.e_content[e_name])
|
||||
|
||||
def is_zero_within_error(self):
|
||||
return np.abs(self.value) <= self.dvalue
|
||||
def is_zero_within_error(self, sigma=1):
|
||||
""" 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):
|
||||
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