Beispiel #1
0
    def __init__(self, func, names, bounds, constraints=[], popsize=10):
        def evalFunc(values):
            return defer.maybeDeferred(func, values)

        self.Nd = len(bounds)
        self.Np = self.Nd * popsize
        self.pm = MockParameterManager()
        if not callable(func):
            raise ValueError(sub("Object '{}' is not callable", func))
        self.evalFunc = evalFunc
        self.counter = 0
        self.running = None
Beispiel #2
0
 def assertWithinTenPercent(self, x, xExpected):
     ratio = x / xExpected
     msg = sub("{} not within 10% of {}", x, xExpected)
     self.assertAlmostEqual(0.1*ratio, 0.1, 2, msg)
Beispiel #3
0
 def assertWithinFivePercent(self, x, xExpected):
     ratio = x / xExpected
     msg = sub("{} not within 5% of {}", x, xExpected)
     self.assertAlmostEqual(0.2*ratio, 0.2, 2, msg)
Beispiel #4
0
 def assertWithinOnePercent(self, x, xExpected):
     ratio = x / xExpected
     msg = sub("{} not within 1% of {}", x, xExpected)
     self.assertAlmostEqual(ratio, 1, 2, msg)
Beispiel #5
0
 def assertItemsEqual(self, a, b):
     for ak, bk in zip(a, b):
         self.assertEqual(ak, bk, sub("{} != {}", a, b))