diff --git a/docs/pyerrors/correlators.html b/docs/pyerrors/correlators.html index f6bd819d..3875f5e9 100644 --- a/docs/pyerrors/correlators.html +++ b/docs/pyerrors/correlators.html @@ -213,7 +213,7 @@ import matplotlib.pyplot as plt import scipy.linalg from .obs import Obs, reweight, correlate, CObs -from .misc import dump_object +from .misc import dump_object, _assert_equal_properties from .fits import least_squares from .linalg import eigh, inv, cholesky from .roots import find_root @@ -251,10 +251,8 @@ if not isinstance(data_input, list): raise TypeError('Corr__init__ expects a list of timeslices.') - # data_input can have multiple shapes. The simplest one is a list of Obs. - # We check, if this is the case if all([(isinstance(item, Obs) or isinstance(item, CObs)) for item in data_input]): - + _assert_equal_properties(data_input) self.content = [np.asarray([item]) for item in data_input] self.N = 1 @@ -1236,10 +1234,8 @@ if not isinstance(data_input, list): raise TypeError('Corr__init__ expects a list of timeslices.') - # data_input can have multiple shapes. The simplest one is a list of Obs. - # We check, if this is the case if all([(isinstance(item, Obs) or isinstance(item, CObs)) for item in data_input]): - + _assert_equal_properties(data_input) self.content = [np.asarray([item]) for item in data_input] self.N = 1 @@ -2170,10 +2166,8 @@ smearing matrix at every timeslice. Other dependency (eg. spatial) are not suppo if not isinstance(data_input, list): raise TypeError('Corr__init__ expects a list of timeslices.') - # data_input can have multiple shapes. The simplest one is a list of Obs. - # We check, if this is the case if all([(isinstance(item, Obs) or isinstance(item, CObs)) for item in data_input]): - + _assert_equal_properties(data_input) self.content = [np.asarray([item]) for item in data_input] self.N = 1 diff --git a/docs/pyerrors/input/json.html b/docs/pyerrors/input/json.html index ade6e240..c9111240 100644 --- a/docs/pyerrors/input/json.html +++ b/docs/pyerrors/input/json.html @@ -89,6 +89,7 @@ from ..obs import Obs from ..covobs import Covobs from ..correlators import Corr +from ..misc import _assert_equal_properties from .. import version as pyerrorsversion @@ -184,20 +185,6 @@ dl.append(ed) return dl - def _assert_equal_properties(ol, otype=Obs): - for o in ol: - if not isinstance(o, otype): - raise Exception("Wrong data type in list.") - for o in ol[1:]: - if not ol[0].is_merged == o.is_merged: - raise Exception("All Obs in list have to be defined on the same set of configs.") - if not ol[0].reweighted == o.reweighted: - raise Exception("All Obs in list have to have the same property 'reweighted'.") - if not ol[0].e_content == o.e_content: - raise Exception("All Obs in list have to be defined on the same set of configs.") - if not ol[0].idl == o.idl: - raise Exception("All Obs in list have to be defined on the same set of configurations.") - def write_Obs_to_dict(o): d = {} d['type'] = 'Obs' @@ -675,20 +662,6 @@ dl.append(ed) return dl - def _assert_equal_properties(ol, otype=Obs): - for o in ol: - if not isinstance(o, otype): - raise Exception("Wrong data type in list.") - for o in ol[1:]: - if not ol[0].is_merged == o.is_merged: - raise Exception("All Obs in list have to be defined on the same set of configs.") - if not ol[0].reweighted == o.reweighted: - raise Exception("All Obs in list have to have the same property 'reweighted'.") - if not ol[0].e_content == o.e_content: - raise Exception("All Obs in list have to be defined on the same set of configs.") - if not ol[0].idl == o.idl: - raise Exception("All Obs in list have to be defined on the same set of configurations.") - def write_Obs_to_dict(o): d = {} d['type'] = 'Obs' diff --git a/docs/pyerrors/misc.html b/docs/pyerrors/misc.html index dfc91b5b..91274d64 100644 --- a/docs/pyerrors/misc.html +++ b/docs/pyerrors/misc.html @@ -147,6 +147,21 @@ data.append(np.sqrt(1 - a ** 2) * rand[i] + a * data[-1]) corr_data = np.array(data) - np.mean(data, axis=0) + means return [Obs([dat], [name]) for dat in corr_data.T] + + +def _assert_equal_properties(ol, otype=Obs): + for o in ol: + if not isinstance(o, otype): + raise Exception("Wrong data type in list.") + for o in ol[1:]: + if not ol[0].is_merged == o.is_merged: + raise Exception("All Obs in list have to be defined on the same set of configs.") + if not ol[0].reweighted == o.reweighted: + raise Exception("All Obs in list have to have the same property 'reweighted'.") + if not ol[0].e_content == o.e_content: + raise Exception("All Obs in list have to be defined on the same set of configs.") + if not ol[0].idl == o.idl: + raise Exception("All Obs in list have to be defined on the same set of configurations.")