From c2c5d24f0da5462ec2d5d2a8121129fc78966e5f Mon Sep 17 00:00:00 2001 From: LSaldyt Date: Thu, 5 Oct 2017 15:03:58 -0600 Subject: [PATCH] TAG: Formula testing code --- copycat/copycat.py | 6 ++---- copycat/temperature.py | 3 +-- multi-run.py | 5 +---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/copycat/copycat.py b/copycat/copycat.py index e5f41e1..c14f1eb 100644 --- a/copycat/copycat.py +++ b/copycat/copycat.py @@ -68,13 +68,11 @@ class Copycat(object): def run(self, initial, modified, target, iterations, testAdjFormulas=False): self.workspace.resetWithStrings(initial, modified, target) - # I (LSaldyt) am very sorry for writing code like this. - # It will soon be deleted. I promise. - if testAdjFormulas: formulas = self.temperature.adj_formulas() else: - formulas = ['original'] + formulas = ['inverse'] + #formulas = ['entropy'] formulaList = [] for formula in formulas: diff --git a/copycat/temperature.py b/copycat/temperature.py index 8538a3e..ea352dd 100644 --- a/copycat/temperature.py +++ b/copycat/temperature.py @@ -1,7 +1,6 @@ import math # Alternate formulas for getAdjustedProbability - def _original(temp, prob): if prob == 0 or prob == 0.5 or temp == 0: return prob @@ -33,7 +32,7 @@ def _inverse_prob(temp, prob): class Temperature(object): def __init__(self): self.reset() - self.adjustmentType = 'original' + self.adjustmentType = 'inverse' self._adjustmentFormulas = { 'original' : _original, 'entropy' : _entropy, diff --git a/multi-run.py b/multi-run.py index a5b58c6..88b1b16 100755 --- a/multi-run.py +++ b/multi-run.py @@ -40,14 +40,11 @@ def main(): originalCount = originalCounts[answer] if originalCount != 0: chi2 += (count + originalCount) ** 2 / originalCount - print((formula, chi2)) - - + print('Chi^2 value for {}:{}'.format(formula, chi2)) #for answer, d in sorted(iter(answers.items()), key=lambda kv: kv[1]['avgtemp']): #print('%s: %d (avg time %.1f, avg temp %.1f)' % (answer, d['count'], d['avgtime'], d['avgtemp'])) - #filename = 'output/{}-{}-{}.csv'.format(a, b, c) #save_answers(answers, filename)