Merge branch 'develop' into documentation

This commit is contained in:
fjosw 2021-11-22 16:07:39 +00:00
commit 1f671762bd
2 changed files with 40 additions and 2 deletions

View file

@ -251,7 +251,6 @@ from . import input
from . import linalg from . import linalg
from . import misc from . import misc
from . import mpm from . import mpm
from . import npr
from . import roots from . import roots
from .version import __version__ from .version import __version__

View file

@ -6,7 +6,6 @@ import h5py
import numpy as np import numpy as np
from ..obs import Obs, CObs from ..obs import Obs, CObs
from ..correlators import Corr from ..correlators import Corr
from ..npr import Npr_matrix
def _get_files(path, filestem): def _get_files(path, filestem):
@ -84,6 +83,46 @@ def read_meson_hd5(path, filestem, ens_id, meson='meson_0', tree='meson'):
return corr return corr
class Npr_matrix(np.ndarray):
def __new__(cls, input_array, mom_in=None, mom_out=None):
obj = np.asarray(input_array).view(cls)
obj.mom_in = mom_in
obj.mom_out = mom_out
return obj
@property
def g5H(self):
"""Gamma_5 hermitean conjugate
Uses the fact that the propagator is gamma5 hermitean, so just the
in and out momenta of the propagator are exchanged.
"""
return Npr_matrix(self,
mom_in=self.mom_out,
mom_out=self.mom_in)
def _propagate_mom(self, other, name):
s_mom = getattr(self, name, None)
o_mom = getattr(other, name, None)
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 is not None else s_mom
def __matmul__(self, other):
return self.__new__(Npr_matrix,
super().__matmul__(other),
self._propagate_mom(other, 'mom_in'),
self._propagate_mom(other, 'mom_out'))
def __array_finalize__(self, obj):
if obj is None:
return
self.mom_in = getattr(obj, 'mom_in', None)
self.mom_out = getattr(obj, 'mom_out', None)
def read_ExternalLeg_hd5(path, filestem, ens_id, order='F'): def read_ExternalLeg_hd5(path, filestem, ens_id, order='F'):
"""Read hadrons ExternalLeg hdf5 file and output an array of CObs """Read hadrons ExternalLeg hdf5 file and output an array of CObs