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): def _assert_equal_properties(ol, otype=Obs):
if not isinstance(ol[0], otype): otype = type(ol[0])
raise Exception("Wrong data type in list.")
for o in ol[1:]: for o in ol[1:]:
if not isinstance(o, otype): if not isinstance(o, otype):
raise Exception("Wrong data type in list.") raise Exception("Wrong data type in list.")
if not ol[0].is_merged == o.is_merged: for attr in ["is_merged", "reweighted", "e_content", "idl"]:
raise Exception("All Obs in list have to have the same state 'is_merged'.") if hasattr(ol[0], attr):
if not ol[0].reweighted == o.reweighted: if not getattr(ol[0], attr) == getattr(o, attr):
raise Exception("All Obs in list have to have the same property 'reweighted'.") raise Exception(f"All Obs in list have to have the same state '{attr}'.")
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.")