ó
šßÈ[c           @` s  d  d l  m Z m Z m Z m Z d  d l Z d  d l Z d  d l j	 Z	 d d l
 m
 Z
 m Z d  d l m Z m Z d  d l Z g  Z xJ d d d d	 g D]6 Z x- d d d d	 g D] Z e j e e f ƒ q³ Wqš Wd d
 d d g Z d d
 g Z e e g Z e e g Z e e e j e
 f ƒ e ƒ ƒ e d f e d
 f g Z e Z y d  d l  Z  Wn e! k
 rpe Z n Xd e" f d „  ƒ  YZ# d e" f d „  ƒ  YZ$ d e" f d „  ƒ  YZ% e j& j' d e ƒ d „  ƒ Z( e j& j' d d ƒ d „  ƒ Z) d „  Z* e j& j+ d ƒ d „  ƒ Z, d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   convolvet   convolve_fft(   t   assert_array_almost_equal_nulpt   assert_array_almost_equalu   >f4u   <f4u   >f8u   <f8u   fillu   wrapu   extendu   interpolatet   TestConvolve1Dc           B` sF  e  Z d  „  Z d „  Z e j j d e ƒ d „  ƒ Z e j j d e	 ƒ d „  ƒ Z
 e j j d e ƒ d „  ƒ Z e j j d e ƒ d	 „  ƒ Z e j j d e j e e e e ƒ ƒ d „  ƒ Z e j j d e j e e e e ƒ ƒ d „  ƒ Z e j j d e j e e ƒ ƒ d „  ƒ Z e j j d e j e e ƒ ƒ d „  ƒ Z RS(   c      
   C` sq   d d d d d d d g } d d d g } t  | | d	 d ƒ} t | t j d
 d d d d d d
 g ƒ d ƒ d S(   uJ   
        Test that convolve works correctly when inputs are lists
        i   i   i   i   i   i   gš™™™™™É?g333333ã?t   boundaryg        gÍÌÌÌÌÌ@g      @gffffff@g333333@i
   N(   R   t   NoneR   t   npt   array(   t   selft   xt   yt   z(    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt	   test_list&   s
    c         C` sv   d d d d d d d g } t  j | ƒ } d d d g } t | | d	 d
 ƒ} t  j t  j | ƒ | k ƒ sr t ‚ d
 S(   uJ   
        Test that convolve works correctly when inputs are lists
        i   i   i   i   i   i   gš™™™™™É?g333333ã?R	   N(   R   R   R   R
   t   allt   AssertionError(   R   t   inlistR   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_input_unmodified1   s
    u   dtype_arrayu   dtype_kernelc         C` sg   t  j d d d g d | ƒ} t  j d d d g d | ƒ} t | | ƒ } | j | j k sc t ‚ d S(   uG   
        Test that 32- and 64-bit floats are correctly handled
        g      ð?g       @g      @t   dtypeg        N(   R   R   R   R   R   (   R   t   dtype_arrayt   dtype_kernelR   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt
   test_dtype=   s    u   convfuncu   boundaryc         C` sb   t  j d d d g d d ƒ} t  j d g d d ƒ} | | | d | ƒ} t  j j | | ƒ d S(   uV   
        Test that a unit kernel with a single element returns the same array
        g      ð?g       @g      @R   u   >f8R	   N(   R   R   t   testingt   assert_allclose(   R   R	   t   convfuncR   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_1_noneK   s    c         C` s²   t  j d d d g d d ƒ} t  j d d d g d d ƒ} t | | d | ƒ} | d k r“ t  j | t  j d d d g d d ƒk ƒ s® t ‚ n t  j | | k ƒ s® t ‚ d S(	   u|   
        Test that a unit kernel with three elements returns the same array
        (except when boundary is None).
        g      ð?g       @g      @R   u   >f8g        R	   N(   R   R   R   R
   R   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_3Y   s    6c         C` sT  t  j d d d g d d ƒ} t  j d d d g d d ƒ} t | | d | d t ƒ} | d k r™ t  j | t  j d d d g d d ƒk ƒ sPt ‚ n· | d	 k rÛ t  j | t  j d d d g d d ƒk ƒ sPt ‚ nu | d
 k rt  j | t  j d d d g d d ƒk ƒ sPt ‚ n3 t  j | t  j d d d g d d ƒk ƒ sPt ‚ d S(   u„   
        Test that the different modes are producing the correct results using
        a uniform kernel with three elements
        g      ð?g        g      @R   u   >f8R	   t   normalize_kernelg      @u   fillu   wrapg       @g      @N(   R   R   R   t   FalseR
   R   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_uniform_3k   s    666u   nan_treatmentu   normalize_kernelu   preserve_nanc         C` s  t  j d t  j d g d d ƒ} t  j d d d g d d ƒ} t | | d | d | d | d	 | ƒ} | rˆ t  j | d
 ƒ sˆ t ‚ n  t  j | ƒ } t  j | ƒ } | d k rè t  j | t  j d d d g d d ƒk ƒ st ‚ n t  j | | k ƒ st ‚ d S(   u½   
        Test that a unit kernel with three elements returns the same array
        (except when boundary is None). This version includes a NaN value in
        the original array.
        g      ð?g      @R   u   >f8g        R	   t   nan_treatmentR   t   preserve_nani   N(	   R   R   t   nanR   t   isnanR   t
   nan_to_numR
   R   (   R   R	   R"   R   R#   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_3_withnan   s    !	6c   	      C` sp  t  j d t  j d g d d ƒ} t  j d d d g d d ƒ} t | | d | d | d | d | ƒ} | rˆ t  j | d	 ƒ sˆ t ‚ n  t  j | ƒ } i d
 d d
 g d d t f 6d
 d d
 g d d t	 f 6d
 d d
 g d d t f 6d
 d d
 g d d t	 f 6d d d g d d t f 6d d d g d d t	 f 6d d d g d d t f 6d	 d d g d d t	 f 6d d d g d d t f 6d d d g d d t	 f 6d d  d! g d d t f 6d d d g d d t	 f 6d	 d d g d d t f 6d d d g d d t	 f 6d" d# d$ g d d t f 6d d d g d d t	 f 6| | | f } | rMd
 | d	 <n  t
 | t  j | d d ƒd ƒ d S(%   uÆ   
        Test that the different modes are producing the correct results using
        a uniform kernel with three elements. This version includes a NaN
        value in the original array.
        g      ð?g      @R   u   >f8R	   R"   R   R#   i   i    i   u   interpolatei   i   u   fillg       @i   i	   u   wrapu   extendi
   NgUUUUUUõ?g      à?g      ø?g      ø?g      @gUUUUUUÕ?gUUUUUUõ?g      ð?gUUUUUUõ?gUUUUUUõ?gUUUUUUõ?gUUUUUUå?gUUUUUUõ?g       @(   R   R   R$   R   R%   R   R&   R
   t   TrueR    R   (	   R   R	   R"   R   R#   R   R   R   t   rslt(    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_uniform_3_withnan¢   s:    !	c      
   C` sL  | r t  j d ƒ n  d d d d d d d d	 d
 g	 } d d d d d	 d d d d g	 } t j t | ƒ d d d ƒs| t ‚ t | | d | d | ƒ} i d d d d d d d d d g	 d+ 6d d d d d d d d d g	 d 6d d d d d d d d  d! g	 d" 6d# d d d d d$ d% d& d g	 d' 6| } t | t j	 | d( d) ƒd* ƒ d+ S(,   uK   
        Test that convolve works correctly with zero sum kernels.
        u(   You can't normalize by a zero sum kerneli   i   i   i   i   i   i   i   i	   iÿÿÿÿi    t   atolg:Œ0âŽyE>R	   R   g        g      Àg      Àg      ð¿g      $@g      5@g     €@@g      G@u   fillg      BÀg      ;Àg      2Àg      "Àg      "@g      2@g      ;@g      B@u   wrapg      $Àg      ð?g      @g      @u   extendR   u   >f8i
   N(
   t   pytestt   xfailR   t   iscloset   sumR   R   R
   R   R   (   R   R	   R   R   R   R   R)   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_zero_sum_kernelÕ   s    !!$""""c         C` sX  | r t  j d ƒ n  d d d d d d d d	 d
 g	 } t j d d d d d	 d d d d g	 d d d d d d d d d d g	 d d ƒ} t | | d | d | ƒ} i d d d d d d d d d g	 d- 6d d d d d d d d d g	 d 6d d d d d d d d  d! g	 d" 6d# d d$ d% d d d& d' d( g	 d) 6| } t | t j | d* d+ ƒd, ƒ d- S(.   uQ   
        Test that convolve works correctly with integer masked kernels.
        u(   You can't normalize by a zero sum kerneli   i   i   i   i   i   i   i   i	   iÿÿÿÿt   maski    t
   fill_valueg        R	   R   g      "@g      ð¿g      @g      @g       @g      $@g      5@g     €@@g      G@u   fillg      ?Àg      5Àg      &Àg      4@g      >@g      D@u   wrapg      Àg      @g      @g      (@g      .@g      3@u   extendR   u   >f8i
   N(   R,   R-   t   maR   R   R
   R   R   (   R   R	   R   R   R   R   R)   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_int_masked_kernelð   s    !Q""""(   u   dtype_arrayu   dtype_kernel(   u   convfuncu   boundary(   u   boundaryu   nan_treatmentu   normalize_kernelu   preserve_nan(   u   boundaryu   nan_treatmentu   normalize_kernelu   preserve_nan(   u   boundaryu   normalize_kernel(   u   boundaryu   normalize_kernel(   t   __name__t
   __module__R   R   R,   t   markt   parametrizet   VALID_DTYPESR   t   BOUNDARIES_AND_CONVOLUTIONSR   t   BOUNDARY_OPTIONSR   R!   t	   itertoolst   productt   NANHANDLING_OPTIONSt   NORMALIZE_OPTIONSt   PRESERVE_NAN_OPTIONSR'   R*   R0   R4   (    (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyR   %   s0   						.		t   TestConvolve2Dc           B` s  e  Z d  „  Z e j j d e ƒ d „  ƒ Z e j j d e ƒ d „  ƒ Z	 e j j d e ƒ d „  ƒ Z
 e j j d e ƒ d „  ƒ Z e j j d e ƒ d „  ƒ Z e j j d e ƒ d	 „  ƒ Z e j j d e ƒ d
 „  ƒ Z e j j d e ƒ d „  ƒ Z RS(   c      	   C` s    d d d g d d d g d d d g g } t  | | d d d d d t ƒ} t | | d ƒ t  | | d d d d d t ƒ} t | t j | t ƒ d d ƒ d S(	   uJ   
        Test that convolve works correctly when inputs are lists
        i   R	   u   fillR2   R   i
   i	   N(   R   R(   R   R    R   R   t   float(   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyR     s    !!u   dtype_arrayu   dtype_kernelc         C` s   t  j d d d g d d d g d d d	 g g d
 | ƒ} t  j d d d g d d d g d d d g g d
 | ƒ} t | | ƒ } | j | j k s™ t ‚ d S(   uG   
        Test that 32- and 64-bit floats are correctly handled
        g      ð?g       @g      @g      @g      @g      @g      @g       @g      "@R   g        N(   R   R   R   R   R   (   R   R   R   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyR     s    u   boundaryc         C` sˆ   t  j d d d g d d d g d d d	 g g d
 d ƒ} t  j d g g d
 d ƒ} t | | d | ƒ} t  j | | k ƒ s„ t ‚ d S(   uD   
        Test that a 1x1 unit kernel returns the same array
        g      ð?g       @g      @g      @g      @g      @g      @g       @g      "@R   u   >f8R	   N(   R   R   R   R   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_1x1_none+  s    c         C` s  t  j d d d g d d d g d d d	 g g d
 d ƒ} t  j d d d g d d d g d d d g g d
 d ƒ} t | | d | ƒ} | d k rä t  j | t  j d d d g d d d g d d d g g d
 d ƒk ƒ sÿ t ‚ n t  j | | k ƒ sÿ t ‚ d S(   ul   
        Test that a 3x3 unit kernel returns the same array (except when
        boundary is None).
        g      ð?g       @g      @g      @g      @g      @g      @g       @g      "@R   u   >f8g        R	   N(   R   R   R   R
   R   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_3x3;  s    *c         C` sÊ  t  j d d d g d d d g d d d g g d d ƒ} t  j d d d g d d d g d d d g g d d ƒ} t | | d | d t ƒ} | d k rß t | t  j d d d g d d	 d g d d d g g d d ƒd
 ƒ nç | d k r1t | t  j d d d g d d	 d g d d d g g d d ƒd
 ƒ n• | d k rƒt | t  j d	 d	 d	 g d	 d	 d	 g d	 d	 d	 g g d d ƒd
 ƒ nC t | t  j d d d g d d	 d g d	 d d g g d d ƒd
 ƒ d S(   uu   
        Test that the different modes are producing the correct results using
        a 3x3 uniform kernel.
        g        g      @g      ð?g       @R   u   >f8R	   R   g      @i
   u   fillg      @g      @u   wrapg      @g      (@g       @N(   R   R   R   R    R
   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_uniform_3x3S  s,    """c      	   C` sI  t  j d d d g d t  j d g d d d g g d	 d
 ƒ} t  j d d d g d d d g d d d g g d	 d
 ƒ} t | | d | d d d t ƒ} t  j | d ƒ s¯ t ‚ t  j | ƒ } t  j | ƒ } | d k r*t  j	 | t  j d d d g d d d g d d d g g d	 d
 ƒk ƒ sEt ‚ n t  j	 | | k ƒ sEt ‚ d S(   u­   
        Test that a 3x3 unit kernel returns the same array (except when
        boundary is None). This version includes a NaN value in the original
        array.
        g      ð?g       @g      @g      @g      @g      @g       @g      "@R   u   >f8g        R	   R"   u   fillR#   i   N(   i   i   (
   R   R   R$   R   R(   R%   R   R&   R
   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_3x3_withnanu  s     	*c      	   C` sî  t  j d d d g d t  j d g d d d g g d d ƒ} t  j d d d g d d d g d d d g g d d ƒ} t | | d | d d	 d
 t ƒ} | d k rè t | t  j d d d g d d d g d d d g g d d ƒd ƒ n| d	 k r:t | t  j d d d g d d d g d d d g g d d ƒd ƒ n° | d k rŒt | t  j d d d g d d d g d d d g g d d ƒd ƒ n^ | d k rÞt | t  j d d d g d d d g d d d g g d d ƒd ƒ n t d ƒ ‚ d S(   u¶   
        Test that the different modes are producing the correct results using
        a 3x3 uniform kernel. This version includes a NaN value in the
        original array.
        g        g      @g      ð?g      @R   u   >f8R	   R"   u   fillR   g       @i
   g      @g      @u   wrapu   extendg       @g      "@g      0@g      &@g      @u   Invalid boundary specificationN(   R   R   R$   R   R    R
   R   t
   ValueError(   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_uniform_3x3_withnanfilled“  s2    	""""c      	   C` sî  t  j d d d g d t  j d g d d d g g d d ƒ} t  j d d d g d d d g d d d g g d d ƒ} t | | d | d d	 d
 t ƒ} | d k rè t | t  j d d d g d d d g d d d g g d d ƒd ƒ n| d k r:t | t  j d d d g d d d g d  d! d" g g d d ƒd ƒ n° | d k rŒt | t  j d d d g d d d g d d d g g d d ƒd ƒ n^ | d k rÞt | t  j d# d$ d% g d& d' d( g d) d* d+ g g d d ƒd ƒ n t d ƒ ‚ d S(,   u¶   
        Test that the different modes are producing the correct results using
        a 3x3 uniform kernel. This version includes a NaN value in the
        original array.
        g        g      @g      ð?g      @R   u   >f8R	   R"   u   interpolateR   i
   u   filli   g      @g       @g      @u   wrapu   extendg       @g      "@g      0@g      &@g      @u   Invalid boundary specificationNg      À?g      ä?g      à?g      à?g      ð?g      ì?g      à?g      à?g      Ø?g      Ð?g      ò?g       @g      ä?g      ð?g      ö?g      ð?g      ì?g      è?(   R   R   R$   R   R(   R
   R   RG   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt    test_uniform_3x3_withnaninterped¹  s2    	""""c      	   C` së  t  j d d d g d d d g d d d g g d d ƒ} t  j d d d g d d d g d d d g g d d ƒ} t | | d	 | d
 d d t ƒ} | d  k rå t | t  j d d d g d d d g d d d g g d d ƒd ƒ n| d k r7t | t  j d d d g d d d g d d d g g d d ƒd ƒ n° | d k r‰t | t  j d d d g d d d g d d d g g d d ƒd ƒ n^ | d k rÛt | t  j d d d g d d d g d d d g g d d ƒd ƒ n t d ƒ ‚ d  S(   Ng        g      @g      ð?g       @g      @R   u   floatg      ð¿R	   R"   u   fillR   i
   g      Àg      Àg       Àu   wrapg       Àg      @g      @g      Àu   extendu   Invalid boundary specification(   R   R   R   R    R
   R   RG   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_non_normalized_kernel_2Dß  s2    	""""(   u   dtype_arrayu   dtype_kernel(   R5   R6   R   R,   R7   R8   R9   R   R;   RC   RD   RE   RF   RH   RI   RJ   (    (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyRA     s   	"&&t   TestConvolve3Dc           B` sï   e  Z d  „  Z e j j d e ƒ d „  ƒ Z e j j d e ƒ d „  ƒ Z	 e j j d e ƒ d „  ƒ Z
 e j j d e ƒ d „  ƒ Z e j j d e j e e ƒ ƒ d	 „  ƒ Z e j j d e ƒ d
 „  ƒ Z e j j d e ƒ d „  ƒ Z RS(   c      	   C` s´   d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g } t  | | d d d d d t ƒ} t | d | d ƒ d S(	   uJ   
        Test that convolve works correctly when inputs are lists
        i   R	   u   fillR2   R   i   i
   N(   R   R    R   (   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyR     s    !u   dtype_arrayu   dtype_kernelc         C` s   t  j d d d g d d d g d d d	 g g d
 | ƒ} t  j d d d g d d d g d d d g g d
 | ƒ} t | | ƒ } | j | j k s™ t ‚ d S(   uG   
        Test that 32- and 64-bit floats are correctly handled
        g      ð?g       @g      @g      @g      @g      @g      @g       @g      "@R   g        N(   R   R   R   R   R   (   R   R   R   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyR     s    u   boundaryc         C` sÜ   t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d	 d d g d
 d d g g g d d ƒ} t  j d g g g d d ƒ} t | | d | ƒ} t  j | | k ƒ sØ t ‚ d S(   uF   
        Test that a 1x1x1 unit kernel returns the same array
        g      ð?g       @g      @g      @g      @g        g      @g      @g       @g      "@R   u   >f8R	   N(   R   R   R   R   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_1x1x1_none%  s    -'6c      
   C` s‹  t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d	 d d g d
 d d g g g d d ƒ} t  j d d d ƒ} d | d <t | | d | ƒ} | d k rlt  j | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒk ƒ s‡t ‚ n t  j | | k ƒ s‡t ‚ d S(   un   
        Test that a 3x3x3 unit kernel returns the same array (except when
        boundary is None).
        g      ð?g       @g      @g      @g      @g      @g      @g        g       @g      "@R   u   >f8i   i   R	   N(   i   i   i   (   i   i   i   (   R   R   t   zerosR   R
   R   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_3x3x35  s    -'6
6'Ec      
   C` s;  t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d	 d d g d
 d d g g g d d ƒ} t  j d= d d ƒ} t | | d | d t ƒ} | d< k r]t | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒd ƒ nÚ| d k r t | t  j d d d g d d d g d d d g g d d d g d d d g d d d  g g d! d d g d d" d# g d d$ d g g g d d ƒd ƒ n7| d% k r£t | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒd ƒ n” t | t  j d& d' d( g d) d* d+ g d, d- d. g g d/ d. d g d0 d d' g d1 d2 d3 g g d4 d5 d6 g d7 d/ d8 g d9 d: d; g g g d d ƒd ƒ d< S(>   uu   
        Test that the different modes are producing the correct results using
        a 3x3 uniform kernel.
        g      ð?g       @g      @g      @g      @g      @g      @g        g       @g      "@R   u   >f8i   R	   R   g     @T@i
   u   fillg      7@g      <@g      0@g     €A@g      G@g      9@g      A@g      2@g      D@g      I@g     €O@g      B@g      N@g      ;@g      @@g     €N@g      6@g      F@u   wrapg     @P@g      K@g     €E@g     ÀR@g     €P@g     €L@g     @U@g     €S@g     ÀQ@g      X@g      [@g      ^@g     ÀV@g      O@g     À_@g      V@g     €H@g      a@g     €I@g     `c@g      Z@g     €J@N(   i   i   i   (   R   R   t   onesR   R    R
   R   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_uniform_3x3x3L  s(    -'63'=3'=3'=3'u   nan_treatmentc      
   C` sÑ  t  j d d d g d d d g d d d g g d d d g d t  j d g d d d g g d d d g d	 d d g d
 d d g g g d d ƒ} t  j d d d ƒ} d | d <t | | d | d | d t ƒ} t  j | d ƒ sæ t ‚ t  j | ƒ } t  j | ƒ } | d k r²t  j
 | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒk ƒ sÍt ‚ n t  j
 | | k ƒ sÍt ‚ d S(   u¯   
        Test that a 3x3x3 unit kernel returns the same array (except when
        boundary is None). This version includes a NaN value in the original
        array.
        g      ð?g       @g      @g      @g      @g      @g      @g        g       @g      "@R   u   >f8i   i   R	   R"   R#   N(   i   i   i   (   i   i   i   (   i   i   i   (   R   R   R$   RM   R   R(   R%   R   R&   R
   R   (   R   R	   R"   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_unity_3x3x3_withnanl  s    
-*6
	6'Ec      
   C` s_  t  j d d d g d d d g d d d g g d d d g d t  j d g d d d g g d d d g d	 d d g d
 d d g g g d d ƒ} t  j d@ d d ƒ} t | | d | d d d t ƒ} | d? k rft | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒd ƒ nõ| d k r	t | t  j d d d g d d d g d d d g g d d d g d d d g d d  d! g g d" d d g d d# d$ g d d% d g g g d d ƒd ƒ nR| d& k r¬t | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒd ƒ n¯ | d' k rOt | t  j d( d) d* g d+ d, d- g d. d/ d0 g g d1 d0 d g d2 d d) g d3 d4 d5 g g d6 d7 d8 g d9 d1 d: g d; d< d= g g g d d ƒd ƒ n t d> ƒ ‚ d? S(A   u¶   
        Test that the different modes are producing the correct results using
        a 3x3 uniform kernel. This version includes a NaN value in the
        original array.
        g      ð?g       @g      @g      @g      @g      @g      @g        g       @g      "@R   u   >f8i   R	   R"   u   fillR   g     €S@i
   g      4@g      9@g      *@g      @@g     €E@g      6@g      ?@g      .@g     €B@g     €G@g      N@g     €@@g     €L@g      8@g      =@g      M@g      3@g     €D@u   wrapu   extendg      O@g     €I@g      D@g      R@g     €O@g      K@g     €T@g     ÀR@g      Q@g     @W@g     @Z@g     @]@g      V@g     €M@g      _@g     @U@g      G@g     @a@g      H@g      c@g     @Y@g      I@u   Invalid Boundary OptionN(   i   i   i   (	   R   R   R$   RO   R   R    R
   R   RG   (   R   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt!   test_uniform_3x3x3_withnan_filled‹  sH    -*6	3'=%3'=c      
   C` s2  t  j d d d g d d d g d d d g g d d d g d t  j d g d d d g g d d d g d	 d d g d
 d d g g g d d ƒ} t  j dB d d ƒ} t | | d | d d d t ƒ} | j ƒ  d } | t  j | ƒ j ƒ  | } | dA k r—t	 | t  j d d d g d d d g d d d g g d d d g d d d g d d d g g d d d g d d d g d d d g g g d d ƒ| d ƒ n—| d k r>t	 | t  j d d d g d d d g d d d g g d d d g d  d d! g d d" d# g g d$ d d g d d% d& g d! d' d g g g d d ƒ| d ƒ nð | d( k r{t	 | t  j
 | j d ƒ d d d g ƒ d ƒ n³ | d) k r"t	 | t  j d* d+ d, g d- d. d/ g d0 d1 d2 g g d3 d2 d g d4 d d+ g d5 d6 d7 g g d8 d9 d: g d; d3 d< g d= d> d? g g g d d ƒ| d ƒ n t d@ ƒ ‚ dA S(C   u¶   
        Test that the different modes are producing the correct results using
        a 3x3 uniform kernel. This version includes a NaN value in the
        original array.
        g      ð?g       @g      @g      @g      @g      @g      @g        g       @g      "@R   u   >f8i   R	   R"   u   interpolateR   i   g     €S@i
   u   fillg      4@g      9@g      *@g      @@g     €E@g      6@g      ?@g      .@g     €B@g     €G@g      N@g     €@@g     €L@g      8@g      =@g      M@g      3@g     €D@u   wrapu   extendg      O@g     €I@g      D@g      R@g     €O@g      K@g     €T@g     ÀR@g      Q@g     @W@g     @Z@g     @]@g      V@g     €M@g      _@g     @U@g      G@g     @a@g      H@g      c@g     @Y@g      I@u   Invalid Boundary OptionN(   i   i   i   (   R   R   R$   RO   R   R(   R/   t   isfiniteR
   R   t   tilet   astypeRG   (   R   R	   R   R   R   t   kernsumt   mid(    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt#   test_uniform_3x3x3_withnan_interped¼  sL    -*6	3'-1(   u   dtype_arrayu   dtype_kernel(   u   boundaryu   nan_treatment(   R5   R6   R   R,   R7   R8   R9   R   R;   RL   RN   RP   R<   R=   R>   RQ   RR   RX   (    (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyRK     s   	 	1u   boundaryc         C` s7  t  j d d d g d d ƒ} t  j d d d g d d ƒ} t | | d	 |  d
 t ƒ} |  d k rŽ t | t  j d d d g d d ƒd ƒ n¥ |  d k rÅ t | t  j d d d g d d ƒd ƒ nn |  d k rü t | t  j d d d g d d ƒd ƒ n7 |  d k r3t | t  j d d d g d d ƒd ƒ n  d S(   uo   
    Regression test for #6264: make sure that asymmetric convolution
    functions go the right direction
    g      @g        g      ð?R   u   >f8i   i   i   R	   R   u   fillg      @g      $@g       @u   floati
   u   extendg      .@u   wrapg      "@g      @N(   R   R   R   R    R   R
   (   R	   R   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_asymmetric_kernelñ  s    +++u   ndimsi   i   c         C` s   t  j j d ƒ t  j j d g |  Œ  } t  j j d ƒ t  j j d g |  Œ  } t | | d d ƒ} t | | d d ƒ} t | | d ƒ d  S(   Ni    i   R	   u   filli   (   R   t   randomt   seedt   randnt   randR   R   R   (   t   ndimsR   t   kernelt   conv_ft   conv_d(    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   test_convolution_consistency  s    c          C` s   t  j d d d g ƒ }  t  j d d d d d g ƒ } t t  j | |  d ƒ t | |  d t ƒƒ t t  j | |  d ƒ t | |  d t ƒƒ d  S(   Ni   i   i   i   i   u   sameR   (   R   R   R   R   R    R   (   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt&   test_astropy_convolution_against_numpy  s    u   not HAS_SCIPYc          C` sš   d d l  m }  t j d d d g ƒ } t j d d d d d g ƒ } t |  | | d ƒ t | | d	 t ƒƒ t |  | | d ƒ t | | d	 t ƒƒ d  S(
   Ni    (   t   fftconvolvei   i   i   i   i   u   sameR   (   t   scipy.signalRd   R   R   R   R   R    R   (   Rd   R   R   (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt&   test_astropy_convolution_against_scipy   s    (   i   i   i   (-   t
   __future__R    R   R   R   R,   t   numpyR   t   numpy.maR3   R   R   t   numpy.testingR   R   R<   R9   R   R   t   appendR
   R;   R>   R(   R    R?   R@   t   listt   zipt   cycleR:   t	   HAS_SCIPYt   scipyt   ImportErrort   objectR   RA   RK   R7   R8   RY   Rb   Rc   t   skipifRf   (    (    (    sF   lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.pyt   <module>   s>   "
æöð	
