docs: def damping_maintain_sign(x, step, damping=1.0, factor=0.5):
      '''Famping function which will maintain the sign of the variable being
      manipulated. If the step puts it at the other sign, the distance between
      `x` and `step` will be shortened by the multiple of `factor`; i.e. if 
      factor is `x`, the new value of `x` will be 0 exactly.
      
      The provided `damping` is applied as well.
      
      Parameters
      ----------
      x : float
          Previous value in iteration, [-]
      step : float
          Change in `x`, [-]
      damping : float, optional
          The damping factor to be applied always, [-]
      factor : float, optional
          If the calculated step changes sign, this factor will be used instead
          of the step, [-]
  
      Returns
      -------
      x_new : float
          The new value in the iteration, [-]
      
      Notes
      -----
      
      Examples
      --------
      >>> damping_maintain_sign(100, -200, factor=.5)
      50.0
      '''
      positive = x > 0.0
      step_x = x + step
      
      if (positive and step_x < 0) or (not positive and step_x > 0.0):
  #        print('damping')
          step = -factor*x
      return x + step*damping