Skip to content
Snippets Groups Projects
Commit 7947351e authored by shinedday's avatar shinedday
Browse files

Add 2 method to add / remove attribute in csv

parent 67030ad5
No related branches found
No related tags found
No related merge requests found
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment