diff --git a/tardis/io/atom_data/base.py b/tardis/io/atom_data/base.py index 9cee040ece6..09d24ddd1d8 100644 --- a/tardis/io/atom_data/base.py +++ b/tardis/io/atom_data/base.py @@ -224,10 +224,10 @@ def from_hdf(cls, fname=None): atom_data = cls(**dataframes) - cls.set_attributes_from_store(store, atom_data.uuid1, "uuid1") - cls.set_attributes_from_store(store, atom_data.md5, "md5") - cls.set_attributes_from_store( - store, atom_data.version, "database_version" + atom_data.uuid1 = cls.get_attributes_from_store(store, "uuid1") + atom_data.md5 = cls.get_attributes_from_store(store, "md5") + atom_data.version = cls.get_attributes_from_store( + store, "database_version" ) # TODO: strore data sources as attributes in carsus @@ -650,18 +650,16 @@ def _check_selected_atomic_numbers(self): def __repr__(self): return f"" - def set_attributes_from_store(store, attribute, store_key): - """Sets arbitrary atom data attributes, throws error and sets to None + def get_attributes_from_store(store, store_key): + """Gets atom_data attributes, throws error and sets to None if they are not available. Parameters ---------- - atom_data : AtomData - The atom data to modify store : pd.HDFStore Data source - property : str - Property to modify + store_key : str + HDFStore value to check """ try: attribute = store.root._v_attrs[store_key] @@ -669,6 +667,8 @@ def set_attributes_from_store(store, attribute, store_key): attribute = (store.root._v_attrs[attribute].decode("ascii"),) except KeyError: logger.debug( - f"{attribute} not available for Atom Data. Setting value to None" + f"{store_key} not available for Atom Data. Setting value to None" ) attribute = None + + return attribute