๓
๎&]\c           @` s  d  Z  d d l m Z m Z m 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 d d l m Z d Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d S(   s    Test functions for rbf module i    (   t   divisiont   print_functiont   absolute_importN(   t   assert_t   assert_array_almost_equalt   assert_almost_equal(   t   linspacet   sint   randomt   expt   allclose(   t   Rbft   multiquadrics   inverse multiquadrict   gaussiant   cubict   quintics
   thin-platet   linearc         C` sq   t  d d d  } t |  } t | | d |  } | |  } t | |  t | t | d   | d  d  S(   Ni    i
   i	   t   function(   R   R   R   R   R   t   float(   R   t   xt   yt   rbft   yi(    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   check_rbf1d_interpolation   s    c         C` s   t  j d d  d d } t  j d d  d d } | t | d d | d  } t | | | d d d |  } | | |  } | j | _ t | |  d  S(   Ni2   i   i   i   y              ๐?t   epsilonR   (   R   t   randR	   R   t   shapeR   (   R   R   R   t   zR   t   zi(    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   check_rbf2d_interpolation   s    !c      	   C` sป   t  j d d  d d } t  j d d  d d } t  j d d  d d } | t | d | d  } t | | | | d d d |  } | | | |  } | j | _ t | |  d  S(   Ni2   i   i   i   R   R   (   R   R   R	   R   R   R   (   R   R   R   R   t   dR   t   di(    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   check_rbf3d_interpolation%   s    !c          C` s3   x, t  D]$ }  t |   t |   t |   q Wd  S(   N(   t	   FUNCTIONSR   R   R    (   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_rbf_interpolation1   s    

c         C` s   t  d d d  } t |  } t | | d |  } t  d d d  } | |  } d t | t |   j   } t t | t |  d | |  d  S(   Ni    i
   i	   R   id   s   abs-diff: %ft   atol(   R   R   R   t   abst   maxR   R
   (   R   R#   R   R   R   t   xiR   t   msg(    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   check_rbf1d_regularity8   s     c          C` se   i d d 6d d 6d d 6d d 6d d 6d d 6d	 d
 6}  x' t  D] } t | |  j | d   q> Wd  S(   Ngน?R   g333333ร?s   inverse multiquadricR   R   R   s
   thin-plategษ?R   g{ฎGแz?(   R!   R(   t   get(   t
   tolerancesR   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_rbf_regularityJ   s    
c         C` sน   t  j j d  t  j d d d  } | d t  j j t |   } t | | d |  } t  j d d d  } | |  } t t  j | |  j	   t  j | |  j	   d k   d  S(	   Niา  i    i
   i2   g      @R   i่  g๑?(
   t   npR   t   seedR   t   randnt   lenR   R   R$   R%   (   R   R   R   R   R&   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   check_rbf1d_stabilityX   s     c          C` s   x t  D] }  t |   q Wd  S(   N(   R!   R0   (   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_rbf_stabilityh   s    c          C` sJ   t  d d d  }  t |   } t |  |  } | |   } t | |  d  S(   Ni    i
   i	   (   R   R   R   R   (   R   R   R   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_default_constructionm   s
    c          C` sY   t  d d d  }  t |   } d   } t |  | d | } | |   } t | |  d  S(   Ni    i
   i	   c         S` s   |  S(   N(    (   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   <lambda>{   s    R   (   R   R   R   R   (   R   R   t   linfuncR   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_function_is_callablew   s    	c          C` sY   d   }  t  d d d  } t |  } t | | d |  } | |  } t | |  d  S(   Nc         S` s   |  j  | S(   N(   R   (   t   selft   r(    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   _func   s    i    i
   i	   R   (   R   R   R   R   (   R8   R   R   R   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt!   test_two_arg_function_is_callable   s    	c          C` s7   t  d d d  }  t |   } t |  | d d  } d  S(   Ni    i
   i	   R   (   R   R   R   t   None(   R   R   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_rbf_epsilon_none   s    c          C` s\   d d d g }  d d d g } d d d g } t  |  | | d d  } t | j d	 k  d  S(
   Ni   i   i   i   i   i   i   R   i    (   R   R:   R   R   (   R   R   R   R   (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   test_rbf_epsilon_none_collinear   s
    (   R   s   inverse multiquadricR   R   R   s
   thin-plateR   (    t   __doc__t
   __future__R    R   R   t   numpyR,   t   numpy.testingR   R   R   R   R   R   R	   R
   t   scipy.interpolate.rbfR   R!   R   R   R    R"   R(   R+   R0   R1   R2   R5   R9   R;   R<   (    (    (    s?   lib/python2.7/site-packages/scipy/interpolate/tests/test_rbf.pyt   <module>   s(   ( 	
								
	
		