Commits

Georg Brandl  committed b0e07d9

params: add a delta() initializer for giving initial step sizes

  • Participants
  • Parent commits 5940454

Comments (0)

Files changed (1)

File ufit/param.py

 
 from ufit import UFitError
 
-__all__ = ['fixed', 'expr', 'overall', 'datapar', 'limited', 'Param',
-           'expr_namespace']
+__all__ = ['fixed', 'expr', 'overall', 'datapar', 'limited', 'delta',
+           'Param', 'expr_namespace']
 
 
 class fixed(str):
     def __new__(self, min, max, v):
         return (min, max, v)
 
+class delta(object):
+    """Give parameter delta together with initial value."""
+    def __init__(self, delta, v):
+        self.delta = delta
+        self.v = v
+
 
 expr_namespace = {
     'data': None,  # replaced by the dataset's metadata dict, but in here
             elif isinstance(pdef, datapar):
                 self.expr = 'data.' + pdef.v
                 pdef = 0
+            elif isinstance(pdef, delta):
+                self.delta = pdef.delta
+                pdef = pdef.v
             elif isinstance(pdef, tuple) and len(pdef) == 3:
                 self.pmin, self.pmax, pdef = pdef
             else: