U
    Gvf                     @   s   d Z ddlZddlmZmZmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZ dZdd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Z d)d* Z!d+d, Z"dS )-z Test functions for rbf module     N)assert_assert_array_almost_equalassert_almost_equal)linspacesincosrandomexpallclose)RbfZmultiquadriczinverse multiquadricZgaussianZcubicZquinticz
thin-plateZlinearc                 C   sR   t ddd}t|}t||| d}||}t|| t|t|d |d  d S )Nr   
   	   function)r   r   r   r   r   float)r   xyrbfyi r   D/tmp/pip-unpacked-wheel-96ln3f52/scipy/interpolate/tests/test_rbf.pycheck_rbf1d_interpolation   s    
r   c                 C   sx   t ddd d }t ddd d }|t|d  d|d    }t|||d| d}|||}|j|_t|| d S )N2                          ?epsilonr   r   randr	   r   shaper   )r   r   r   zr   zir   r   r   check_rbf2d_interpolation   s    
r%   c                 C   s   t ddd d }t ddd d }t ddd d }|t|d  |d   }t||||d| d}||||}|j|_t|| d S )Nr   r   r   r   r   r    )r   r   r   r#   dr   dir   r   r   check_rbf3d_interpolation#   s    r(   c                  C   s&   t D ]} t|  t|  t|  qd S N)	FUNCTIONSr   r%   r(   r   r   r   r   test_rbf_interpolation/   s    r+   c                 C   sl   t ddd}t|}t|}t||gj}t||| dd}||}t|| t|t	|d |d  d S )Nr   r   r   N-Dr   mode)
r   r   r   npvstackTr   r   r   r   )r   r   y0y1r   r   r   r   r   r   check_2drbf1d_interpolation6   s    
r4   c                 C   s   t dd d }t dd d }|t|d  d|d    }|t|d  d|d    }t||gj}t|||d| dd}|||}|j|_t|| d S )Nr   r   r   r   r,   r   r   r.   	r   r!   r	   r/   r0   r1   r   r"   r   )r   r   r   Zz0Zz1r#   r   r$   r   r   r   check_2drbf2d_interpolationB   s    
r7   c           	   	   C   s   t dd d }t dd d }t dd d }|t|d  |d   }|t|d  |d   }t||gj}t||||d| dd}||||}|j|_t|| d S )Nr   r   r   r,   r5   r6   )	r   r   r   r#   Zd0d1r&   r   r'   r   r   r   check_2drbf3d_interpolationO   s    r9   c                  C   s&   t D ]} t|  t|  t|  qd S r)   )r*   r4   r7   r9   r   r   r   r   test_2drbf_interpolation]   s    r:   c                 C   sj   t ddd}t|}t||| d}t ddd}||}dt|t|   }tt|t||d| d S )Nr   r   r   r   d   abs-diff: %fatol)r   r   r   absmaxr   r
   )r   r>   r   r   r   xir   msgr   r   r   check_rbf1d_regularityd   s    rC   c                  C   s4   dddddddd} t D ]}t|| |d qd S Ng?g333333?g?r   g{Gz?)r*   rC   getZ
tolerancesr   r   r   r   test_rbf_regularityp   s    	rG   c           
      C   s   t ddd}t|}t|}t||gj}t||| dd}t ddd}||}dt|tt|t|gj   }	t	t
|tt|t|gj|d|	 d S )	Nr   r   r   r,   r-   r;   r<   r=   )r   r   r   r/   r0   r1   r   r?   r@   r   r
   )
r   r>   r   r2   r3   r   r   rA   r   rB   r   r   r   check_2drbf1d_regularity~   s    (rH   c                  C   s4   dddddddd} t D ]}t|| |d qd S rD   )r*   rH   rE   rF   r   r   r   test_2drbf_regularity   s    	rI   c                 C   s   t jd t ddd}|dt jt|  }t||| d}t ddd}||}tt || 	 t || 	  dk  d S )	Ni  r   r   r   g      @r   i  g?)
r/   r   seedr   Zrandnlenr   r   r?   r@   )r   r   r#   r   rA   r   r   r   r   check_rbf1d_stability   s    rL   c                  C   s   t D ]} t|  qd S r)   )r*   rL   r   r   r   r   test_rbf_stability   s    rM   c                  C   s4   t ddd} t| }t| |}|| }t|| d S )Nr   r   r   r   r   r   r   )r   r   r   r   r   r   r   test_default_construction   s
    
rO   c                  C   s@   t ddd} t| }dd }t| ||d}|| }t|| d S )Nr   r   r   c                 S   s   | S r)   r   )r   r   r   r   <lambda>       z+test_function_is_callable.<locals>.<lambda>r   rN   )r   r   Zlinfuncr   r   r   r   r   test_function_is_callable   s    rR   c                  C   s@   dd } t ddd}t|}t||| d}||}t|| d S )Nc                 S   s
   | j | S r)   r   )selfrr   r   r   _func   s    z0test_two_arg_function_is_callable.<locals>._funcr   r   r   r   rN   )rV   r   r   r   r   r   r   r   !test_two_arg_function_is_callable   s    rW   c                  C   s&   t ddd} t| }t| |d d d S )Nr   r   r   rS   )r   r   r   )r   r   r   r   r   test_rbf_epsilon_none   s    rX   c                  C   s@   dddg} dddg}dddg}t | ||d d}t|jd	k d S )
Nr   r      r            rS   r   )r   r   r   )r   r   r#   r   r   r   r   test_rbf_epsilon_none_collinear   s
    


r]   )#__doc__Znumpyr/   Znumpy.testingr   r   r   r   r   r   r   r	   r
   Zscipy.interpolate._rbfr   r*   r   r%   r(   r+   r4   r7   r9   r:   rC   rG   rH   rI   rL   rM   rO   rR   rW   rX   r]   r   r   r   r   <module>   s0    


