
n,2Jc        s   @   s
  d  Z  d d k Z d d k l Z d e f d     YZ d e f d     YZ e d e d	 e i	 d
 d d d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dj dk dl dm gd  dn e i	 do dp dq dr ds dt du dv dw dx dy dz d{ d| d} d~ d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d gd   d e d	 e i	 d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d g!  dn e i	 d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d g!   d e d	 e i	 d d d d d d d d d d d d d d d d d d d d d d d d d g  dn e i	 d d d d d d d d d d d d d d dddd d ddddddg   d	e d	 e i	 d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmgd  dn e i	 dndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddgd   de d	 e i	 dd d d d d d d d d ddddddddd d d d d d d d d dddddddddd d d d d d d d d dddddddddd d d d d d d d d dddddddddd d d d d d d d d gQ  dn e i	 d dd dd dd dd d dd dd dd dd d dd dd dd dd d dd dd dd dd d dd dd dd dd d dd dd dd dd d dd dd dd dd d dd dd dd dd d dd dd dd dd gQ    Z
 d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ d  Z de _ e e e e e e e e e e g
 Z de f d    YZ de f d    YZ e d Z d d Z d d Z d d Z  ddd Z! de e
 dd Z" d  Z# d S(  s   Some test functions for bivariate interpolation.

Most of these have been yoinked from ACM TOMS 792.
http://netlib.org/toms/792
iN(   t   Triangulationt   TestDatac           B   s   e  Z d    Z RS(   c         O   s    t  i |  | |  |  |  _ d  S(   N(   t   dictt   __init__t   __dict__(   t   selft   argst   kwds(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyR      s    (   t   __name__t
   __module__R   (    (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyR   
   s   t   TestDataSetc           B   s   e  Z d    Z RS(   c         K   s   |  i  i |  d  S(   N(   R   t   update(   R   R   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyR      s    (   R   R	   R   (    (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyR
      s   t	   franke100t   xg??gXk?gj*0	8?g1P?gDQW-_?g$@gj!>?g=;gr;+?gjGqgXo>?g]43?g?g-?g10f?gYHe/?g0	?gFQ?g?gl[jα?g?g؝<?gc3?g?g}l?g?g@yp?gTF?gMe?g<?glq?g9d?g䢵?gIgX?grOg8/?gZ+?g!?goMg?gi
SJ?g^jG?gE?g1`?gcK?gU꣝?gÖÓ?g
`0?gV(?gyp?gX()u?ge)\?gKg??gV?g`g?g9qa?gjC/H_?gM
Jъ?gMn+?gUV7?gT_?g<Zt?g`,?g鮑?g+w?g>s?g^g?gzD?gY3?g,0?g	t&?go*Ral?g?g m-n?ga?ga*m?gaa?gĹҌ?gTXI?g7~T?g	Tb?gd%?gHh?gȉe?g*.?gFn#?gAG!?gjDǄ?gM»\?g4R?g& ?gg=?g쉮??gYcuP.?g[X?g9?g?4?gk3?g0!?gHg+?grک?g{`lO?t   ygMZ:ßgܩoO?gC`C~?gWA?gNr?g#bP?g9a?gH:?g{n$?gXx?gV?g-u׃?g:ܳS?g5|f?g-?gśD?gBF?gl?gvD?g+?g%Y8?gt֮?gŠ?gJ6?gX*?g~?g!I?gO<1?gUY?g-L`?gØR?gvՅ?gq%?g N?g0a?gbVD?g?g:@@?gm?gi?ge%guBY?gL;?gKR?gE?gkٵE?gu<?g-U	?g6g*?g,2?g+|"؛g ҥI?gV?gA?geB?gabx?g:P?g9'?gcCb?g
x~?g5?g?gW?g@?gC\L?gwl_N?gh>n?g`?g#?g'0l?g~8?gk%?g?g,g~?g%+?gۆQ<~?gC|:ed?gϭH?g1е/ ?gYxM?gm;F{?gb5i?g[8?g
@=?g_/?gg?gXZ/?gt@?gu?gO?g~Tg?g`@?gnZ:0J?gG	~"?gd$?g~6?g+r>+?gsZ\?grP]?t   franke33g?g        g?g333333?g?g      ?g333333?gffffff?g      ?g?g333333?g?gffffff?g      ?g?g333333?g?gffffff?g      ?g?g?t   lawson25g?g333333?g?g?ggffffff?gffffff?g333333?g333333g      ?g?g      ?g?g?g333333?g?gffffff?g?gffffff?gffffff?g?gffffff?g      ?g      ?g333333?gffffff?g?g?g      ?g\(\g̼?t	   random100gͯA?gnn'?gLT?g
_?gŸ́p?g.Ҭ?g{=?g+|"?g{y<_?gփ?g=l?gGAk?g=?g6k?ge?gRm?g㌼?gv@#"?g+~?g@5_%?gHțW?g3?gnxL{?g{6?g¦Σ?gUP?gr-?g' t?gf`X~?gQC?gmB<?gbt/?gvS?gY#?gC0t*?gt1HW?g"F?gΎl?g'jD?gG?gg4v?gJ<EW?g$-pm?guI?g!Z<?gԘփ?g5Odu?g>߹?gOP?g.eT>:?gW:?gA0HR-?g/892?g+r?gv5ԃ?ghfً?g8?gn&?g.a#?g6qr?ghju(?g{<)?gT?g?g @+ժB?gz?g<?g2?g6S!^?gH?g60~
?g̏d5?gǮ?g̉A?gTqsj?gYq`(?g%?g1Ð6?g9ݞ֣?g7F6?g|k?g4
U ?g+n7?g7ne?gG{r4?g0o{?gO5?g&"?g7G?gmz?g*z;#?g5?gÑ?g *s?gv?g+	0?gz^?gd?g=FE?g/;z?gu1r?g]?gxv?gZ?g":vY?gy?gS?ga7?gyD;]?gir?g/s昇?gu=,/?g<.ED?g'?gt	޺?gd4<0?g߃.?g ?gȮYa*?gZh?g*d?g^:?g}?g~^G	?g1߃|?g/fS?gm3⑰?gDd7?gܾh?g+??g	*|l?gL?gcK?gzN?gv?g8<Y{)?gϳԷ?gX?g0עh[?gOR?gM&?g_ .?g^-wf?g_2k?g6#ޕ?gL!F?gNɃ>?g3?gxO/B?gq;?ggJF)|Q?gүc?g=?giW|?gp@k?gxr+?gbg?gʔ m?gq Ģ?g#)ah?gC?gG?gC9,h5?gU?gd&?gBe?g>.X?gͨq?gI^Bͤ?gtٞ?gtE?g
a=?g?gҕcrr?g:-~?gAAΠ?ggs?g>m?gf{Y?g`T?g8賨?gqo#
q?gGF?gnA?gS?g>A?g\?g~۰?g*|.	?g)?gtPxb?gBme[M?gp6G?gpצw?gk:1?gR?g5rT?gGH?gj$SO0m?g?t   uniform9g      ?g      ?g      ?c         C   s   t  i |  i |  i  S(   N(   t   npt   onest   shapet   dtype(   R   R   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   constant   s    t   Constantc         C   s   |  S(   N(    (   R   R   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   xramp   s    s   X Rampc         C   s   | S(   N(    (   R   R   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   yramp   s    s   Y Rampc         C   s   |  d }  | d } |  d } |  d } |  d } |  d } |  d } | d } | d } | d }	 d t  i | | | | d  d t  i | | d | d	  d
 t  i | | | | d  d t  i | | |	 |	  }
 |
 S(   Ni	   g      ?g       @g      @g      @g      @g      ?g     H@g      $@g      ?g?(   R   t   exp(   R   R   t   x1t   x2t   x4t   x7t   y1t   y2t   y3t   y7t   f(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   exponential   s    









e!s   Exponential and Some Gaussiansc         C   s#   t  i d | |  d  d } | S(   Ng      "@g      ?(   R   t   tanh(   R   R   R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   cliff   s    t   Cliffc         C   s3   d t  i d |  d d d |  d d } | S(   Ng      ?g@g      @i   g      ?i   (   R   t   cos(   R   R   R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   saddle   s    /t   Saddlec         C   s/   t  i d |  d d | d d  d } | S(   Ng     @g      ?i   g      @(   R   R   (   R   R   R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   gentle   s    +s   Gentle Peakc         C   s/   t  i d |  d d | d d  d } | S(   Ng     @4g      ?i   g      @(   R   R   (   R   R   R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   steep   s    +s
   Steep Peakc         C   s]   d d |  d d | d d } t  i | d j t  i t  i | d d   d d  } | S(   Ni@   iQ   g      ?i   i    id   g        (   R   t   wheret   sqrtt   clip(   R   R   t   circleR$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   sphere   s    "7t   Spherec         C   sA   d t  i d |   t  i d |  t  i d |  |  } | S(   Ng       @g      $@(   R   R)   t   sin(   R   R   R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   trig   s    =s   Cosines and Sinesc         C   sf   d d |  }  d d | } t  i |  |  d  } t  i | | d  } | d | d | } | S(   Ng      @g      $@i   g      ?i   (   R   R   (   R   R   t   g1t   g2R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   gauss   s    s!   Gaussian Peak and Gaussian Ridgesc         C   s   t  i d d |  d  } t  i d d | d  } d d | } d d | } d d d | | d | | d | d | | d | } | S(	   Ng      $@g      4@g      @g      ?i   i   i   g       @(   R   R   (   R   R   t   ext   eyt   logitxt   logityR$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt
   cloverleaf	  s    >t
   Cloverleafc         C   sJ   t  i d |  d d | d  } t  i d |  t  i d |  } | S(   NiP   g      D@iZ   g     F@g{Gzg333333?(   R   t   hypotR   R)   (   R   R   R1   R$   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   cosine_peak  s    "$s   Cosine Peakt   LinearTesterc           B   sD   e  Z d  Z d
 d d d d  Z d   Z d   Z e d d	  Z RS(   t   Linearg        g      ?ie   i   c         C   s   | |  _  | |  _ | |  _ | |  _ t i i d  } | i | d | d d | |  _ | i | d | d d | |  _	 t
 |  i |  i	  |  _ d  S(   NiIi    i   t   size(   t   xranget   yranget   nranget   npointsR   t   randomt   RandomStatet   uniformR   R   R    t   tri(   R   RD   RE   RF   RG   t   rng(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyR     s    				##c         C   s4   | i  |  _  | i |  _ t |  i  |  i  |  _ d  S(   N(   R   R   R    RK   (   R   t   dataset(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   replace_data)  s    c         C   s5   | |  i  |  i  } |  i i | d |  i |  i S(   Nt   bbox(   R   R   RK   t   linear_extrapolatorRD   RE   (   R   t   funct   z(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   interpolator.  s    t   imshowc         C   s>  d d  k  } d d k  l } | oi |  i |  } | |  i d |  i d t d |  i   |  i d |  i d t d |  i   f } no t i |  i d |  i d t d |  i   |  i d |  i d t d |  i   f \ } }	 | |	 |  } t i	 t i
 |  d |  } |  i d |  i d |  i d |  i d f }
 | i   | i   | i   | d j o, | i t i |  d d d	 |
 d
 d n | d j o t i |  i d |  i d t d |  i   |  i d |  i d t d |  i   f \ } } | i t i |  t i |  | d  n |  i }	 |  i } | i i t i g  } |  i i D]5 \ } } | |	 | | | f |	 | | | f f qg~  d d g } | i   } | i |  | o d |  i } n d } t | d  o | i d | i | f  n | i |  | i   | i    d  S(   Ni(   t   pylabi    i   g        RT   t   interpolationt   nearestt   extentt   origint   lowert   contouri   t   colorsg?s   %s Interpolantt	   Referencet   titles   %s: %s(   i    i    i    g?(!   t
   matplotlibRU   RS   RE   t   complexRF   RD   R   t   mgridR.   t   isinft   iofft   clft   hotRT   t
   nan_to_numt   ogridR[   t   ravelR   R   t   collectionst   LineCollectiont   arrayRK   t   edge_dbt   gcat   add_collectiont   namet   hasattrR^   t   showt   ion(   R   RQ   t   interpt   plottert   mplt   plt   lpiRR   R   R   RX   t   Yt   Xt   _[1]t   it   jt   lct   axR^   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   plot2  sF    )1,3


,,3,		W
(   g        g      ?(   g        g      ?(   R   R	   Ro   R   RN   RS   t   TrueR   (    (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyRA     s
   		t   NNTesterc           B   s   e  Z d  Z d   Z RS(   s   Natural Neighborsc         C   s5   | |  i  |  i  } |  i i | d |  i |  i S(   NRO   (   R   R   RK   t   nn_extrapolatorRD   RE   (   R   RQ   RR   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyRS   `  s    (   R   R	   Ro   RS   (    (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyR   ^  s   c         C   sm  d d k  l } | i   t d d  } t d d  } x$|  D]} | i GH| i | d t d d | i d | i	  | i | d t
 d d | i d	 | i	  | i | d t
 d d | i d
 | i	  | i | d t d d | i d | i	  | i | d t
 d d | i d | i	  | i | d t
 d d | i d | i	  q? W| i   d  S(   Ni(   RU   RG   i  Rs   Rt   RT   s   %s-ref-img.pngs   %s-nn-img.pngs   %s-lin-img.pngR[   s   %s-ref-con.pngs   %s-nn-con.pngs   %s-lin-con.png(   R_   RU   Rc   R   RA   R^   R   t   Falset   savefigt	   func_nameR   Rr   (   t   allfuncsRv   t   nntt   lptRQ   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   plotallfuncsd  s(    
 c   	      C   s   d d  k  } d d k  l } | d  j o d g } n | i i t i g  } |  i D]A \ } } | |  i | |  i	 | f |  i | |  i	 | f f qS ~  d | } | i
   } | i |  | i   d  S(   Ni(   RU   i    g?R\   (   i    i    i    g?(   R_   RU   t   NoneRi   Rj   R   Rk   Rl   R   R   Rm   Rn   t   draw_if_interactive(	   RK   R\   Ru   Rv   Rz   R{   R|   R}   R~   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   plot_dty  s    ]c   	      C   s   d d  k  } d d k  l } | d  j o d g } n | i i t i g  } t t |  i	   D]F } |  i
 | D]2 } | d j o | |  i	 | |  i	 | f qp qp q_ ~  d | } | i   } | i |  | i   d  S(   Ni(   RU   i    i   g?R\   (   i    i   i    g?(   R_   RU   R   Ri   Rj   R   Rk   RD   t   lent   circumcenterst   triangle_neighborsRm   Rn   R   (	   RK   R\   Ru   Rv   Rz   R{   R|   R}   R~   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   plot_vo  s    L	c         C   s2  d d  k  } d d k  l } | d  j o
 d } n t i g  } |  i D]* \ } } } | |  i | |  i | f qG ~  |  i } t i	 | d  d   d f | d  d   d f  }	 | i
   }
 x_ t t |	   D]K } | i i |  i | |	 | d d d | d	 d d
 d } |
 i |  q W| i   d  S(   Ni(   RU   i    i   g?t
   resolutionid   t	   edgecolort	   facecolort	   linewidth(   i    i    i   g?(   i   i   i   i    (   R_   RU   R   R   Rk   t   triangle_nodesR   R   R   R?   Rm   RD   R   t   patchest   Circlet	   add_patchR   (   RK   R   Ru   Rv   Rz   R{   R|   t   kt   dxyt   rR~   t   p(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   plot_cc  s    
G
2 )t   nni!   c         C   sS  |  | i  | i  } t | i  | i  } t | | d  | d d } t i d d t d |   d d t d |   f \ } } |  | |  }	 | d d t d |   d d t d |   f }
 | | } |	 |
 d } t i | i  } t i |	 i  | } |	 | d } t i | i  } d | | } |  i	 G| G| G| G| GH| S(	   sn   Compute a quality factor (the quantity r**2 from TOMS792).

    interpolator must be in ('linear', 'nn').
    t   _extrapolatorRO   g        g      ?i    i   i   (   g        g      ?g        g      ?(
   R   R   R    t   getattrR   Ra   R`   t   sumt   flatR   (   RQ   t   meshRS   t   nt   fzRK   t   intpRx   Ry   t   Zt   izt   numgoodt   SEt   SSEt   meanZt   SMt   SSMt   r2(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   quality  s    =4
c   
      C   sv   h  } | i    } | i   xS | D]K \ } } | i | g   } x* | D]" }	 | i t |	 | |  |   qH Wq# W| S(   N(   t   itemst   sortt
   setdefaultt   appendR   (
   RS   R   t   dataR   t   resultst   kvRo   R   t   reslistRQ   (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt
   allquality  s    
  $c          C   s   t  i d d d d d g  }  t  i d d d d d g  } d	 } d
 } t |  |  } t t  i |  | g f  t  i | | g f   } | | f S(   Ng      ?g333333?g      ?g333333?g?gffffff?g        g?gq=
ףp?gq=
ףp?(   R   Rk   R    t   hstack(   t   x0t   y0t   txt   tyt   t0t   t1(    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   funky  s    3($   t   __doc__t   numpyR   t   triangulateR    R   R   t   objectR
   Rk   R   R   R^   R   R   R%   R'   R*   R,   R-   R2   R5   R8   R=   R@   R   RA   R   R   R   R   R   R   R   R   R   (    (    (    sM   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\delaunay\testfuncs.pyt   <module>   s  																		!																																																																												$B