U
    `»{jÊ  ã                   @   s   d Z ddlZddd„ZdS )z,Data preparation / preprocessing algorithms.é    N©g        g      ð?ç•Ö&è.>c                 C   s    |d |d kst ‚|  ¡ |  ¡ f}|d |d  |k r\|d |d  d }t | j|¡}n<| |d  }||d |d  |d |d   9 }||d 7 }||fS )aå  Changes the scale of an array

    Parameters
    ----------
    x : ndarray
        1D array to change the scale (remains unchanged)
    new_range : tuple (float, float)
        Desired range of the array
    eps: float
        Numerical precision, to detect degenerate cases (for example, when
        every value of *x* is equal)

    Returns
    -------
    ndarray
        Scaled array
    tuple (float, float)
        Previous data range, allowing a rescale to the old range
    é   r   g       @)ÚAssertionErrorÚminÚmaxÚnpÚfullÚshape)ÚxZ	new_rangeÚepsZrange_ZmeanZxp© r   úP/var/www/html/bwave/python/venv/lib/python3.8/site-packages/peakutils/prepare.pyÚscale   s    $r   )r   r   )Ú__doc__Únumpyr   r   r   r   r   r   Ú<module>   s   