diff --git a/copycat/codeletMethods.py b/copycat/codeletMethods.py index 60c7e89..712d3bc 100644 --- a/copycat/codeletMethods.py +++ b/copycat/codeletMethods.py @@ -14,6 +14,7 @@ from correspondence import Correspondence from workspaceFormulas import chooseUnmodifiedObject from workspaceFormulas import chooseBondFacet + def codelet(name): """Decorator for otherwise-unused functions that are in fact used as codelet behaviors""" def wrap(f): @@ -23,6 +24,7 @@ def codelet(name): return f return wrap + # some methods common to the codelets def __showWhichStringObjectIsFrom(structure): if not structure: diff --git a/copycat/randomness.py b/copycat/randomness.py index 9011b3b..d5dd99b 100644 --- a/copycat/randomness.py +++ b/copycat/randomness.py @@ -2,12 +2,14 @@ import bisect import math import random + def accumulate(iterable): total = 0 for v in iterable: total += v yield total + class Randomness(object): def __init__(self, seed=None): self.rng = random.Random(seed) diff --git a/copycat/temperature.py b/copycat/temperature.py index 99727f1..f00e479 100644 --- a/copycat/temperature.py +++ b/copycat/temperature.py @@ -1,5 +1,6 @@ import math + class Temperature(object): def __init__(self): self.reset() diff --git a/copycat/tests.py b/copycat/tests.py index c3c5ee0..e55e197 100644 --- a/copycat/tests.py +++ b/copycat/tests.py @@ -1,9 +1,8 @@ -"""Run the copycat program""" - import unittest from context import Context + def pnormaldist(p): table = { 0.80: 1.2815, @@ -21,7 +20,8 @@ def pnormaldist(p): 0.99999999: 5.7307, 0.999999999: 6.1094, } - return max(v for k,v in table.iteritems() if k <= p) + return max(v for k, v in table.iteritems() if k <= p) + def lower_bound_on_probability(hits, attempts, confidence=0.95): if attempts == 0: @@ -33,6 +33,7 @@ def lower_bound_on_probability(hits, attempts, confidence=0.95): denominator = (1 + zsqr / attempts) return (phat + zsqr / (2*attempts) - z * (under_sqrt ** 0.5)) / denominator + def upper_bound_on_probability(hits, attempts, confidence=0.95): misses = attempts - hits return 1.0 - lower_bound_on_probability(misses, attempts, confidence) @@ -131,5 +132,6 @@ class TestCopycat(unittest.TestCase): 'kitten': {'count': 4, 'avgtemp': 68}, }) + if __name__ == '__main__': unittest.main()