diff --git a/pyAmakCore/classes/tools/loggable.py b/pyAmakCore/classes/tools/loggable.py index a74ba82837f2ee142aa621989c80e10dad95c939..094e4f0ab9ce6789398d85a181a4872de0e8b58b 100644 --- a/pyAmakCore/classes/tools/loggable.py +++ b/pyAmakCore/classes/tools/loggable.py @@ -14,6 +14,7 @@ class Loggable: def __init__(self): self.__do_log = False self.__file_path = None + self.__ignore_attribute = ["_Agent__amas", "_Agent__environment"] def to_csv(self, cycle: int, var_list: List['Agent']) -> None: """ @@ -22,8 +23,7 @@ class Loggable: if not self.__do_log: return - ignore_attribute = ["_Agent__amas", "_Agent__environment"] - table = [{**{e: x[e] for e in x if e not in ignore_attribute}, + table = [{**{e: x[e] for e in x if e not in self.__ignore_attribute}, **{'nombre_cycle': cycle}} for x in map(vars, var_list)] dataframe = DataFrame(table) @@ -46,3 +46,17 @@ class Loggable: specify path to csv """ self.__file_path = path_to_file + + def add_ignore_attribute(self, attribute: str) -> None: + """ + add attribute in ignored attribute + """ + self.__ignore_attribute.append(attribute) + + def remove_ignore_attribute(self, attribute: str) -> None: + """ + remove attribute in ignored attribute + """ + if attribute not in self.__ignore_attribute: + return + self.__ignore_attribute.remove(attribute)