mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 23:00:25 +01:00
refactor: moved _assert_equal_properties from input.json to misc
This commit is contained in:
parent
c8ec5909f1
commit
78ff4bb117
2 changed files with 17 additions and 14 deletions
|
@ -9,6 +9,7 @@ import warnings
|
||||||
from ..obs import Obs
|
from ..obs import Obs
|
||||||
from ..covobs import Covobs
|
from ..covobs import Covobs
|
||||||
from ..correlators import Corr
|
from ..correlators import Corr
|
||||||
|
from ..misc import _assert_equal_properties
|
||||||
from .. import version as pyerrorsversion
|
from .. import version as pyerrorsversion
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,20 +105,6 @@ def create_json_string(ol, description='', indent=1):
|
||||||
dl.append(ed)
|
dl.append(ed)
|
||||||
return dl
|
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):
|
def write_Obs_to_dict(o):
|
||||||
d = {}
|
d = {}
|
||||||
d['type'] = 'Obs'
|
d['type'] = 'Obs'
|
||||||
|
|
|
@ -70,3 +70,19 @@ def gen_correlated_data(means, cov, name, tau=0.5, samples=1000):
|
||||||
data.append(np.sqrt(1 - a ** 2) * rand[i] + a * data[-1])
|
data.append(np.sqrt(1 - a ** 2) * rand[i] + a * data[-1])
|
||||||
corr_data = np.array(data) - np.mean(data, axis=0) + means
|
corr_data = np.array(data) - np.mean(data, axis=0) + means
|
||||||
return [Obs([dat], [name]) for dat in corr_data.T]
|
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.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue