a
    ߙfb                     @   sh  d dl Z d dlZd dlZd dlmZmZ d dlmZ	 d dl
mZmZ d dlmZmZmZ d dlmZ d dlmZ ddgd	d	ggZd
d
gddgddggZddggZg dZg Zee D ]ZeD ]Zeeeed  ed ddd eeeed  ed ddd eeeed  ed ddd eeeded  ed ddd qqG dd dZdd Zdd ZdS )    N)assert_almost_equalassert_allclose)units)convolveconvolve_fft)Gaussian2DKernelBox2DKernelTophat2DKernel)Moffat2DKernel)AstropyDeprecationWarning                )               
oversample
   )Zx_sizeZy_sizemodefactorr   c                	   @   s   e Zd Zejdedd Zejdedd Zejde	e
eedd Zejde	e
eg d	d
d ZdS )Test2DConvolutionskernelc                 C   sZ   |j j}t|}tdd |D }d||< t||dd}t||dd}t||dd dS )	zI
        Test smoothing of an image with a single positive pixel
        c                 S   s"   g | ]}t |d  |d  d qS r   r   slice.0Zsh r!   Nlib/python3.9/site-packages/astropy/convolution/tests/test_convolve_kernels.py
<listcomp><       z?Test2DConvolutions.test_centered_makekernel.<locals>.<listcomp>      ?fillboundary   decimalN)arrayshapenpzerostupler   r   r   )selfr   r-   xxslicec2c1r!   r!   r"   test_centered_makekernel3   s    
z+Test2DConvolutions.test_centered_makekernelc                 C   sB   |j j}tjj| }t||dd}t||dd}t||dd dS )zA
        Test smoothing of an image made of random noise
        r&   r'   r)   r*   N)r,   r-   r.   ZrandomZrandnr   r   r   )r1   r   r-   r2   r4   r5   r!   r!   r"   test_random_makekernelD   s
    z)Test2DConvolutions.test_random_makekernel)r-   widthc                 C   sp   |d dkrdS t ||g}t |}tdd |D }d||< t||dd}t||dd}t||d	d
 dS )zn
        Test smoothing of an image with a single positive pixel

        Uses a simple, small kernel
        r   r   Nc                 S   s"   g | ]}t |d  |d  d qS r   r   r   r!   r!   r"   r#   c   r$   z?Test2DConvolutions.test_uniform_smallkernel.<locals>.<listcomp>r%   r&   r'   r)   r*   )r.   onesr/   r0   r   r   r   )r1   r-   r8   r   r2   r3   r4   r5   r!   r!   r"   test_uniform_smallkernelT   s    
z+Test2DConvolutions.test_uniform_smallkernel)r   r   r   c           	      C   s   t ||gt|d  }t|ddd}t |}tdd |D }d||< t||dd	}t||dd	}t||d
d t||dd	}t||dd	}t||d
d dS )z
        Test smoothing of an image with a single positive pixel

        Compares a small uniform kernel to the Box2DKernel
        r   r   r   )r   r   c                 S   s"   g | ]}t |d  |d  d qS r   r   r   r!   r!   r"   r#   w   r$   zCTest2DConvolutions.test_smallkernel_Box2DKernel.<locals>.<listcomp>r%   r&   r'   r)   r*   N)	r.   r9   floatr   r/   r0   r   r   r   )	r1   r-   r8   kernel1kernel2r2   r3   r4   r5   r!   r!   r"   test_smallkernel_Box2DKernelk   s    
z/Test2DConvolutions.test_smallkernel_Box2DKernelN)__name__
__module____qualname__pytestZmarkZparametrizeKERNELSr6   r7   list	itertoolsproduct
SHAPES_ODDWIDTHSr:   r>   r!   r!   r!   r"   r   1   s   


r   c                  C   s:   t dddtj d} t ddtjd d}t| j|j d S )Nr   r   -   )Zx_stddevZy_stddevZtheta)r   uZdegr.   Zpir   r,   )r<   r=   r!   r!   r"    test_gaussian_2d_kernel_quantity   s    rK   c                  C   sx   ddl m} m} tt | d W d    n1 s80    Y  tt |d W d    n1 sj0    Y  d S )Nr   MexicanHat1DKernelMexicanHat2DKernelr   )Zastropy.convolutionrM   rN   rB   Zwarnsr   rL   r!   r!   r"   test_deprecated_hat   s
    &rO   )rE   rB   Znumpyr.   Znumpy.testingr   r   Zastropyr   rJ   Zastropy.convolution.convolver   r   Zastropy.convolution.kernelsr   r   r	   r
   Zastropy.utils.exceptionsr   rG   ZSHAPES_EVENZNOSHAPErH   rC   r-   r8   appendr   rK   rO   r!   r!   r!   r"   <module>   sT   

T