
    HR-e]                     R   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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z   D ]ZeD ]Ze                     eeed          ed         dd                     e                     eeed          ed         dd                     e                     eeed          ed         dd                     e                     eeded          ed         dd                      G d d          Zd ZdS )    N)assert_allcloseassert_almost_equal)units)convolveconvolve_fft)Box2DKernelGaussian2DKernelMoffat2DKernelTophat2DKernel                )               
oversample
   )x_stddevx_sizey_sizemodefactor)widthr   r   r   r   )radiusr   r   r   r   r   )gammaalphar   r   r   r   c            
          e Zd Zej                            de          d             Zej                            de          d             Zej                            d e	 e
j        ee                              d             Zej                            d e	 e
j        eg d                              d             ZdS )	Test2DConvolutionskernelc                     |j         j        }t          j        |          }t	          d |D                       }d||<   t          ||d          }t          ||d          }t          ||d           dS )zI
        Test smoothing of an image with a single positive pixel
        c              3   H   K   | ]}t          |d z  |d z  dz             V  dS r   r   Nslice.0shs     Olib/python3.11/site-packages/astropy/convolution/tests/test_convolve_kernels.py	<genexpr>z>Test2DConvolutions.test_centered_makekernel.<locals>.<genexpr>N   8      CCruR1WbAgk22CCCCCC          ?fillboundary   decimalN)arrayshapenpzerostupler   r   r   )selfr#   r8   xxslicec2c1s          r,   test_centered_makekernelz+Test2DConvolutions.test_centered_makekernelE   s     "HUOOCCUCCCCC&	!Vf555a&111BB//////r/   c                     |j         j        }t          j        j        | }t          ||d          }t          ||d          }t          ||d           dS )zA
        Test smoothing of an image made of random noise
        r1   r2   r4   r5   N)r7   r8   r9   randomrandnr   r   r   )r<   r#   r8   r=   r?   r@   s         r,   test_random_makekernelz)Test2DConvolutions.test_random_makekernelV   sa     "IOU#!Vf555a&111 	BB//////r/   )r8   r   c                    |dz  dk    rdS t          j        ||g          }t          j        |          }t          d |D                       }d||<   t	          ||d          }t          ||d          }t          ||d	           dS )
zn
        Test smoothing of an image with a single positive pixel

        Uses a simple, small kernel
        r   r   Nc              3   H   K   | ]}t          |d z  |d z  dz             V  dS r&   r'   r)   s     r,   r-   z>Test2DConvolutions.test_uniform_smallkernel.<locals>.<genexpr>w   r.   r/   r0   r1   r2   r4   r5   )r9   onesr:   r;   r   r   r   )r<   r8   r   r#   r=   r>   r?   r@   s           r,   test_uniform_smallkernelz+Test2DConvolutions.test_uniform_smallkernelf   s     19>>F%((HUOOCCUCCCCC&	!Vf555a&111BB//////r/   )r   r   r   c                    t          j        ||g          t          |          dz  z  }t          |dd          }t          j        |          }t          d |D                       }d||<   t          ||d          }t          ||d          }t          ||d	
           t          ||d          }t          ||d          }t          ||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              3   H   K   | ]}t          |d z  |d z  dz             V  dS r&   r'   r)   s     r,   r-   zBTest2DConvolutions.test_smallkernel_Box2DKernel.<locals>.<genexpr>   r.   r/   r0   r1   r2   r4   r5   N)	r9   rH   floatr   r:   r;   r   r   r   )	r<   r8   r   kernel1kernel2r=   r>   r?   r@   s	            r,   test_smallkernel_Box2DKernelz/Test2DConvolutions.test_smallkernel_Box2DKernel   s     '5%.))E%LLA,==e,rBBBHUOOCCUCCCCC&	!Wv666!Wv666BB////a6222a6222BB//////r/   N)__name__
__module____qualname__pytestmarkparametrizeKERNELSrA   rE   list	itertoolsproduct
SHAPES_ODDWIDTHSrI   rO    r/   r,   r"   r"   D   s       [Xw//0 0 0/0  [Xw//0 0 0/0 [DD!2!2:v!F!FGG 0 0 0, [DD!2!2:yyy!I!IJJ 0 0 0 0 0r/   r"   c                      t          dddt          j        z            } t          ddt          j        dz            }t          | j        |j                   d S )Nr   r   -   )r   y_stddevtheta)r	   udegr9   pir   r7   )rM   rN   s     r,    test_gaussian_2d_kernel_quantityrd      sP    AR!%ZHHHGARUQYGGGGGM7=11111r/   )rX   numpyr9   rS   numpy.testingr   r   astropyr   ra   astropy.convolution.convolver   r   astropy.convolution.kernelsr   r	   r
   r   rZ   SHAPES_EVENNOSHAPEr[   rV   r8   r   appendr"   rd   r\   r/   r,   <module>rm      sq            > > > > > > > >       ? ? ? ? ? ? ? ?            2hR!
1vBx"b*$<.	
'! (
 (
E '
 '
QxQx!  	
 	
 	
 	KQxQx!  	
 	
 	
 	NQxQx!  	
 	
 	
 	NQxQx!  		
 		
 		
 		
='
TT0 T0 T0 T0 T0 T0 T0 T0n2 2 2 2 2r/   