Cleans table generation and transposes output
This commit is contained in:
@ -24,22 +24,27 @@ def main(args):
|
|||||||
tableItems = key_sorted_items(crossTable)
|
tableItems = key_sorted_items(crossTable)
|
||||||
assert len(tableItems) > 0, 'Empty table'
|
assert len(tableItems) > 0, 'Empty table'
|
||||||
|
|
||||||
with open('output/cross_compare.csv', 'w') as outfile:
|
headKey, headSubDict = tableItems[0]
|
||||||
headKey, headSubDict = tableItems[0]
|
# Create table and add headers
|
||||||
cells = ['problems x variants']
|
table = [['problems x variants']]
|
||||||
for subkey, subsubdict in key_sorted_items(headSubDict):
|
for subkey, subsubdict in key_sorted_items(headSubDict):
|
||||||
for subsubkey, result in key_sorted_items(subsubdict):
|
for subsubkey, result in key_sorted_items(subsubdict):
|
||||||
cells.append('{} x {} for {} x {}'.format(*subkey, *subsubkey))
|
table[-1].append('{} x {} for {} x {}'.format(*subkey, *subsubkey))
|
||||||
outfile.write(','.join(cells) + '\n')
|
|
||||||
|
|
||||||
for key, subdict in tableItems:
|
# Add test results to table
|
||||||
cells = []
|
for key, subdict in tableItems:
|
||||||
problem = '{}:{}::{}:_'.format(*key)
|
table.append([])
|
||||||
cells.append(problem)
|
problem = '{}:{}::{}:_'.format(*key)
|
||||||
for subkey, subsubdict in key_sorted_items(subdict):
|
table[-1].append(problem)
|
||||||
for subsubkey, result in key_sorted_items(subsubdict):
|
for subkey, subsubdict in key_sorted_items(subdict):
|
||||||
cells.append(str(result))
|
for subsubkey, result in key_sorted_items(subsubdict):
|
||||||
outfile.write(','.join(cells) + '\n')
|
table[-1].append(str(result))
|
||||||
|
|
||||||
|
# A simple transpose
|
||||||
|
table = list(map(list, zip(*table)))
|
||||||
|
|
||||||
|
with open('output/cross_compare.csv', 'w') as outfile:
|
||||||
|
outfile.write('\n'.join(','.join(row) for row in table) + '\n')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user