mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
refactor: _assert_equal_properties simplified.
This commit is contained in:
parent
c01d822ec8
commit
313dec7cee
1 changed files with 5 additions and 10 deletions
|
@ -105,16 +105,11 @@ def gen_correlated_data(means, cov, name, tau=0.5, samples=1000):
|
|||
|
||||
|
||||
def _assert_equal_properties(ol, otype=Obs):
|
||||
if not isinstance(ol[0], otype):
|
||||
raise Exception("Wrong data type in list.")
|
||||
otype = type(ol[0])
|
||||
for o in ol[1:]:
|
||||
if not isinstance(o, otype):
|
||||
raise Exception("Wrong data type in list.")
|
||||
if not ol[0].is_merged == o.is_merged:
|
||||
raise Exception("All Obs in list have to have the same state 'is_merged'.")
|
||||
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.")
|
||||
for attr in ["is_merged", "reweighted", "e_content", "idl"]:
|
||||
if hasattr(ol[0], attr):
|
||||
if not getattr(ol[0], attr) == getattr(o, attr):
|
||||
raise Exception(f"All Obs in list have to have the same state '{attr}'.")
|
||||
|
|
Loading…
Add table
Reference in a new issue