Use variable-length method arguments for convenience

This commit is contained in:
Jose Gracia 2024-02-21 14:41:19 +01:00
parent 20cf200053
commit c2b5732be8

View file

@ -141,11 +141,11 @@ class Power:
def body(self):
_body = ""
for epoch in self.epochs:
_body += self.pretty_print(self.summarize_epoch(epoch))
_body += self.pretty_print(*self.summarize_epoch(epoch))
return _body
def summarize_time(self, ts):
return Power.to_csv((ts, ""))
return Power.to_csv(ts, "")
@staticmethod
def summarize_values(df):
@ -154,7 +154,7 @@ class Power:
min, max = values.min(), values.max()
avg, stddev = values.mean(), values.std()
median = np.median(values)
return Power.to_csv((head, avg, median, min, max, stddev))
return Power.to_csv(head, avg, median, min, max, stddev)
def summarize_epoch(self, epoch):
ts, values = epoch
@ -187,12 +187,12 @@ class Power:
return "# Total energy consumed by job: {energy:.0f} J\n".format(energy=self.energy_total())
@staticmethod
def to_csv(args):
def to_csv(*args):
return ",".join(str(a) for a in args)
@staticmethod
def pretty_print(args):
return Power.to_csv(args) + '\n'
def pretty_print(*args):
return Power.to_csv(*args) + '\n'
def filename(self, jobid):
fname = "detailed_power_{jobid}.hawk-pbs5.{first}-{last}.csv".format(