o
    h                     @   sd   d Z ddlZddlmZ ddlmZmZ G dd dZG dd dZG d	d
 d
Z	G dd dZ
dS )zfTest functions for fftpack.helper module

Copied from fftpack.helper by Pearu Peterson, October 2005

    N)assert_array_almost_equal)fftpic                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestFFTShiftc                 C   sd   g d}g d}t t|| t t|| g d}g d}t t|| t t|| d S )N	r               )	r   r   r   r   r   r   r   r	   r
   
r   r   r   r	   r
   r   r   r   r   )
r   r   r   r   r   r   r   r   r	   r
   r   r   fftshift	ifftshift)selfxy r   o/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/numpy/fft/tests/test_helper.pytest_definition   s   zTestFFTShift.test_definitionc                 C   s2   dD ]}t j|f}ttt|| qd S )N)r   r
   	   d      )nprandomr   r   r   r   )r   nr   r   r   r   test_inverse   s   zTestFFTShift.test_inversec                 C   s   g dg dg dg}g dg dg dg}t tj|dd| t tj|d	dtj|d
d t tj|dd| t tj|d	dtj|d
d t t|| t t|| d S )N)r   r   r   )r	   r
   r   )r   r   r   )r   r   r   )r   r   r   )r   r	   r
   r   r   axesr   r   r   )r   freqsshiftedr   r   r   test_axes_keyword   s   zTestFFTShift.test_axes_keywordc                 C   sv  ddgddgddgg}ddgddgddgg}t tj|dd| t tj|dd| t tj|dd| t tj|dgd| ddgddgddgg}t tj|dd| t tj|dd| ddgddgddgg}t tj|d	d| t tj|d	d| t tj|ddgd| t tj|ddgd| t tj|d
d| t tj|d
d| t t|| t t|| d
S )z1 Test 2D input, which has uneven dimension sizes r   r   r   r	   r
      r"   r$   r!   Nr   )r   r%   
shift_dim0
shift_dim1shift_dim_bothr   r   r   test_uneven_dims)   s<   zTestFFTShift.test_uneven_dimsc                    s   ddl mmm m d
 fdd	}d
 fdd	}tdD ]-}tdD ]&}d	D ]!}tj||}t	t
||||| t	t
||||| q.q*q$dS )z\ Test that the new (>=v1.15) implementation (see #10073) is equal to the original (<=v1.14) r   )asarrayconcatenatearangetakeNc           	         s~   | }|j }|du rtt|}nt|tr|f}|}|D ]}|j| }|d d } || |f}|||}q|S )z& How fftshift was implemented in v1.14Nr   r   ndimlistrange
isinstanceintshape	r   r#   tmpr2   r   kr   p2mylistr/   r-   r.   r0   r   r   original_fftshiftZ   s   

z>TestFFTShift.test_equal_to_original.<locals>.original_fftshiftc           	         s   | }|j }|du rtt|}nt|tr|f}|}|D ] }|j| }||d d  } || |f}|||}q|S )z( How ifftshift was implemented in v1.14 Nr   r   r1   r8   r=   r   r   original_ifftshiftj   s   

z?TestFFTShift.test_equal_to_original.<locals>.original_ifftshift   )r   r   Nr$   r!   )N)numpy._corer-   r.   r/   r0   r4   r   r   randr   r   r   r   )r   r>   r?   ijaxes_keywordinpr   r=   r   test_equal_to_originalV   s    z#TestFFTShift.test_equal_to_originalN)__name__
__module____qualname__r   r    r'   r,   rG   r   r   r   r   r      s    
-r   c                   @      e Zd Zdd ZdS )TestFFTFreqc                 C   p   g d}t dtd | t dt tdt | g d}t dtd | t dt tdt | d S )Nr   r   r   
   )r   r   fftfreqr   r   r   r   r   r   r         zTestFFTFreq.test_definitionNrH   rI   rJ   r   r   r   r   r   rL          rL   c                   @   rK   )TestRFFTFreqc                 C   rM   )N)r   r   r   r	   r
   r   )r   r   r   r	   r
   r(   rN   )r   r   rfftfreqr   rP   r   r   r   r      rQ   zTestRFFTFreq.test_definitionNrR   r   r   r   r   rT      rS   rT   c                   @   rK   )
TestIRFFTNc                 C   s2   t jd\}}|d|  }d}tj||d d S )N)r   r@          y              ?)r   r"   )r   r   r   irfftn)r   araiar#   r   r   r   test_not_last_axis_success   s   z%TestIRFFTN.test_not_last_axis_successN)rH   rI   rJ   r]   r   r   r   r   rV      rS   rV   )__doc__numpyr   numpy.testingr   r   r   r   rL   rT   rV   r   r   r   r   <module>   s    }