From 8217e116ddb6e0f1a3095e440e383b8971612416 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 19 Dec 2019 16:16:15 +0100 Subject: SimulationResult: Handle 0 duration and missing MAE values --- lib/automata.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/automata.py b/lib/automata.py index d977164..8f938bc 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -40,14 +40,25 @@ class SimulationResult: :param parameters: Parameter values after simulation run """ self.duration = duration * 1e-6 - self.duration_mae = duration_mae * 1e-6 - self.duration_mape = self.duration_mae * 100 / self.duration + if duration_mae is None or self.duration == 0: + self.duration_mae = None + self.duration_mape = None + else: + self.duration_mae = duration_mae * 1e-6 + self.duration_mape = self.duration_mae * 100 / self.duration self.energy = energy * 1e-12 - self.energy_mae = energy_mae * 1e-12 - self.energy_mape = self.energy_mae * 100 / self.energy + if energy_mae is None or self.energy == 0: + self.energy_mae = None + self.energy_mape = None + else: + self.energy_mae = energy_mae * 1e-12 + self.energy_mape = self.energy_mae * 100 / self.energy self.end_state = end_state self.parameters = parameters - self.mean_power = self.energy / self.duration + if self.duration > 0: + self.mean_power = self.energy / self.duration + else: + self.mean_power = 0 class PTAAttribute: -- cgit v1.2.3