code: def unwrap(sig, max_delta=pi, step=2*pi):
    
    idata = iter(sig)
    d0 = next(idata)
    yield d0
    delta = d0 - d0 # Get the zero (e.g., integer, float) from data
    for d1 in idata:
      d_diff = d1 - d0
      if abs(d_diff) > max_delta:
        delta += - d_diff + min((d_diff) % step,
                                (d_diff) % -step, key=lambda x: abs(x))
      yield d1 + delta
      d0 = d1
docs: Parametrized signal unwrapping.
  
    Parameters
    ----------
    sig :
      An iterable seen as an input signal.
    max_delta :
      Maximum value of :math:`\Delta = sig_i - sig_{i-1}` to keep output
      without another minimizing step change. Defaults to :math:`\pi`.
    step :
      The change in order to minimize the delta is an integer multiple of this
      value. Defaults to :math:`2 . \pi`.
  
    Returns
    -------
    The signal unwrapped as a Stream, minimizing the step difference when any
    adjacency step in the input signal is higher than ``max_delta`` by
    summing/subtracting ``step``.