refactor: _assert_equal_properties simplified.

This commit is contained in:
Fabian Joswig 2022-12-20 17:18:25 +01:00
parent c01d822ec8
commit 313dec7cee
No known key found for this signature in database

View file

@ -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}'.")