B
    &]\                 @   s   d Z ddlmZmZmZ ddlZddlmZ ej	fddZ
ejdd	d
d Zejdd	dd Zejdd	dd Zejdd	dd Zejdd	dd ZdS )z; helper_funcs.py.
    scavenged from enthought,interpolate
    )divisionprint_functionabsolute_importN   )_interpolatec             C   s   t t | |S )N)np
atleast_1dZascontiguousarray)ZaryZdtype r	   Dlib/python3.7/site-packages/scipy/interpolate/interpolate_wrapper.pyatleast_1d_and_contiguous
   s    r   z&'nearest' is deprecated in SciPy 1.0.0)messagec             C   s   t t | d d g| dd f}td| |  }t|}d}t ||| d }t t |dt jt	}t j
||dd}|S )a  
    Rounds each new x to nearest input x and returns corresponding input y.

    Parameters
    ----------
    x : array_like
        Independent values.
    y : array_like
        Dependent values.
    new_x : array_like
        The x values to return the interpolate y values.

    Returns
    -------
    nearest : ndarray
        Rounds each `new_x` to nearest `x` and returns the corresponding `y`.

    r   r   g      ?g|=)axis)r   ZconcatenateZarrayr   searchsortedr   clipInfastypeinttake)xynew_xZ	shifted_xZmidpoints_of_xTINYindicesnew_yr	   r	   r
   nearest   s    &r   z%'linear' is deprecated in SciPy 1.0.0c             C   s   t | tj} t |tj}t |tj}|jdkr6tdt|jdkrt|jd t|ftj}xPtt|D ]}t	
| || |||  qnW n"tt|tj}t	
| ||| |S )a  
    Linearly interpolates values in new_x based on the values in x and y

    Parameters
    ----------
    x : array_like
        Independent values
    y : array_like
        Dependent values
    new_x : array_like
        The x values to return the interpolated y values.

       z+`linear` only works with 1-D or 2-D arrays.r   )r   r   float64ndim
ValueErrorlenshapezerosranger   Zlinear_dddd)r   r   r   r   ir	   r	   r
   linear/   s    
r%   z*'logarithmic' is deprecated in SciPy 1.0.0c             C   s   t | tj} t |tj}t |tj}|jdkr6tdt|jdkrt|jd t|ftj}xPtt|D ]}t	
| || |||  qnW n"tt|tj}t	
| ||| |S )a  
    Linearly interpolates values in new_x based in the log space of y.

    Parameters
    ----------
    x : array_like
        Independent values.
    y : array_like
        Dependent values.
    new_x : array_like
        The x values to return interpolated y values at.

    r   z+`linear` only works with 1-D or 2-D arrays.r   )r   r   r   r   r   r    r!   r"   r#   r   Zloginterp_dddd)r   r   r   r   r$   r	   r	   r
   logarithmicO   s    
r&   z2'block_average_above' is deprecated in SciPy 1.0.0c             C   s   d}t | tj} t |tj}t |tj}|jdkr:tdt|jdkrt|jd t|ftj}xZtt|D ]&}t	
| || ||| }|dk	rrP qrW n"tt|tj}t	| |||}|dk	rd||| | d | d f }t||S )a  
    Linearly interpolates values in new_x based on the values in x and y.

    Parameters
    ----------
    x : array_like
        Independent values.
    y : array_like
        Dependent values.
    new_x : array_like
        The x values to interpolate y values.

    Nr   z+`linear` only works with 1-D or 2-D arrays.r   zVblock_average_above cannot extrapolate and new_x[%d]=%f is out of the x range (%f, %f)r   )r   r   r   r   r   r    r!   r"   r#   r   Zblock_averave_above_ddddZblock_average_above_dddd)r   r   r   Z	bad_indexr   r$   msgr	   r	   r
   block_average_aboveo   s(    
r(   z$'block' is deprecated in SciPy 1.0.0c             C   sH   d}t | || d }t t |dt jt}t j||dd}|S )a  
    Essentially a step function.

    For each `new_x`, finds largest j such that``x[j] < new_x[j]`` and
    returns ``y[j]``.

    Parameters
    ----------
    x : array_like
        Independent values.
    y : array_like
        Dependent values.
    new_x : array_like
        The x values used to calculate the interpolated y.

    Returns
    -------
    block : ndarray
        Return array, of same length as `x_new`.

    g|=r   r   r   )r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r	   r	   r
   block   s
    r)   )__doc__Z
__future__r   r   r   Znumpyr    r   r   r   Z	deprecater   r%   r&   r(   r)   r	   r	   r	   r
   <module>   s   !  *