1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-03-03 16:57:51 +00:00

utils/rendering: frame collectors should respect column order

Previously FrameCollector.write_frames used "columns" argument only as a
filter for which columns to write, but the order would always be the
same as in raw output.

The Instrument API requires that the column ordering in the resulting
MeasurementsCsv matches the ordering of channels specified in reset()
(if any). This means the collectors should respect the ordering
specified in the "columns" parameter (which gets populated based on
active channels).
This commit is contained in:
Sergei Trofimov 2017-09-19 13:48:08 +01:00
parent 50dfb297cd
commit d952abf52e

View File

@ -83,9 +83,14 @@ class FrameCollector(threading.Thread):
header = self.header
frames = self.frames
else:
header = [c for c in self.header if c in columns]
indexes = [self.header.index(c) for c in header]
indexes = []
for c in columns:
if c not in self.header:
msg = 'Invalid column "{}"; must be in {}'
raise ValueError(msg.format(c, self.header))
indexes.append(self.header.index(c))
frames = [[f[i] for i in indexes] for f in self.frames]
header = columns
with open(outfile, 'w') as wfh:
writer = csv.writer(wfh)
if header: