Adds problems and result saving

This commit is contained in:
LSaldyt
2017-10-04 15:20:48 -06:00
parent 430e2b3750
commit 7abb40f849
6 changed files with 26 additions and 2 deletions
+1
View File
@@ -1,2 +1,3 @@
from .copycat import Copycat, Reporter # noqa from .copycat import Copycat, Reporter # noqa
from .plot import plot_answers from .plot import plot_answers
from .io import save_answers
+9
View File
@@ -0,0 +1,9 @@
def save_answers(answers, filename):
answers = sorted(answers.items(), key=lambda kv : kv[1]['count'])
keys = [k for k, v in answers]
counts = [str(v['count']) for k, v in answers]
with open(filename, 'w') as outfile:
outfile.write(','.join(keys))
outfile.write('\n')
outfile.write(','.join(counts))
View File
+9
View File
@@ -0,0 +1,9 @@
abc,abd,ijk
aabc,aabd,ijkk
abc,abd,kji
abc,abd,mrrjjj
abc,abd,rssttt
abc,abd,xyz
abc,abd,ijjkkk
rst,rsu,xyz
abc,abd,xyyzzz
1 abc abd ijk
2 aabc aabd ijkk
3 abc abd kji
4 abc abd mrrjjj
5 abc abd rssttt
6 abc abd xyz
7 abc abd ijjkkk
8 rst rsu xyz
9 abc abd xyyzzz
+4
View File
@@ -0,0 +1,4 @@
abc,abd,ijk
aabc,aabd,ijkk
abc,abd,xyz
abc,abd,ijjkkk
1 abc abd ijk
2 aabc aabd ijkk
3 abc abd xyz
4 abc abd ijjkkk
+3 -2
View File
@@ -35,8 +35,7 @@ final temperature of the workspace; lower means "more elegant".
import argparse import argparse
import logging import logging
from copycat import Copycat, Reporter, plot_answers from copycat import Copycat, Reporter, plot_answers, save_answers
class SimpleReporter(Reporter): class SimpleReporter(Reporter):
"""Reports results from a single run.""" """Reports results from a single run."""
@@ -70,6 +69,8 @@ def main():
if options.plot: if options.plot:
plot_answers(answers, show=not options.noshow) plot_answers(answers, show=not options.noshow)
save_answers(answers, 'output/answers.csv')
if __name__ == '__main__': if __name__ == '__main__':
main() main()