From d8b435651c4b6a10f0b4ecc0bd8e63b6ea7102ec Mon Sep 17 00:00:00 2001 From: OscarFdezS Date: Thu, 27 Jun 2024 11:30:19 +0200 Subject: [PATCH] Fixed Tests --- xdevs/examples/gpt/models.py | 5 +++-- xdevs/plugins/transducers/csv.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xdevs/examples/gpt/models.py b/xdevs/examples/gpt/models.py index a0000fd..3433493 100644 --- a/xdevs/examples/gpt/models.py +++ b/xdevs/examples/gpt/models.py @@ -14,11 +14,12 @@ def __init__(self, name: str): Job event class. It represents a job sent by the generator and processed by the processor. :param name: job name """ - self.name: str = name + self.name: str = str(name) self.time: float = 0 def __str__(self): return self.name + class Generator(Atomic): def __init__(self, name: str, gen_t: float): """ @@ -240,7 +241,7 @@ def __init__(self, name: str, gen_t: float, proc_t: float, obs_t: float): self.add_in_port(self.ih_in) # New output handler port - self.oh_out = Port(Job, name='ih_in') + self.oh_out = Port(Job, name='oh_out') self.add_out_port(self.oh_out) self.add_component(gen) diff --git a/xdevs/plugins/transducers/csv.py b/xdevs/plugins/transducers/csv.py index aa2bdc2..1a569bf 100644 --- a/xdevs/plugins/transducers/csv.py +++ b/xdevs/plugins/transducers/csv.py @@ -50,6 +50,7 @@ def bulk_data(self, sim_time: float): for state_insert in self._iterate_state_inserts(sim_time): self.state_csv_writer.writerow([state_insert[field] for field in self.state_header]) + for event_insert in self._iterate_event_inserts(sim_time): self.event_csv_writer.writerow([event_insert[field] for field in self.event_header]) @@ -58,7 +59,7 @@ def _create_csv_file(self, filename: str, header: list[str]): os.makedirs(os.path.dirname(filename), exist_ok=True) # 3. Create output CSV file and write the header row. - csv_file = open(filename, 'w') + csv_file = open(filename,newline='', mode='w') writer = csv.writer(csv_file, delimiter=self.delimiter) writer.writerow(header)