Beispiel #1
0
 def testUpdateValues(self):
     if IGNORE_TEST:
         return
     MULT = 10
     parameters = [SBstoat.Parameter(n, lower=l, upper=u, value=v*MULT)
           for n, l, u, v in zip(PARAMETER_NAMES, LOWERS, UPPERS, VALUES)]
     parametersCollection = [[parameters[0]], [parameters[0], parameters[2]],
           [parameters[1]]]
     parametersCollection = [ModelFitter.mkParameters(c)
           for c in parametersCollection]
     for oldParameters, newParameters in zip(PARAMETERS_COLLECTION,
           parametersCollection):
         self.manager.updateValues(newParameters)
         oldValuesDct = oldParameters.valuesdict()
         newValuesDct = newParameters.valuesdict()
         trues = [oldValuesDct[k]*MULT == newValuesDct[k]
               for k in newValuesDct.keys()]
         self.assertTrue(all(trues))
Beispiel #2
0
IGNORE_TEST = False
IS_PLOT = False
NAME = "parameter"
LOWER = 1
UPPER = 11
VALUE = 5
MODEL_NAMES = ["W", "X", "Y", "Z"]
PARAMETER_NAMES = ["A", "B", "C"]
LOWERS = [10, 20, 30]
UPPERS = [100, 200, 300]
VALUES = [15, 25, 35]
PARAMETERS = [SBstoat.Parameter(n, lower=l, upper=u, value=v)
      for n, l, u, v in zip(PARAMETER_NAMES, LOWERS, UPPERS, VALUES)]
PARAMETERS_COLLECTION = [[PARAMETERS[0]], [PARAMETERS[0], PARAMETERS[2]],
      [PARAMETERS[1]]]
PARAMETERS_COLLECTION = [ModelFitter.mkParameters(c)
      for c in PARAMETERS_COLLECTION]
METHODS = [SBstoat.OptimizerMethod("differential_evolution", {cn.MAX_NFEV: 100})]
METHODS = [SBstoat.OptimizerMethod("leastsq", {cn.MAX_NFEV: 100})]



def mkRepeatedList(list, repeat):
    return [list for _ in range(repeat)]


################ TEST CLASSES #############
class TestParameter(unittest.TestCase):

    def setUp(self):
        self.parameter = _Parameter(NAME, lower=LOWER,