HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/numpy/fft/tests/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/numpy/fft/tests/__pycache__/test_pocketfft.cpython-36.pyc
3

���h�%�
@s�ddlZddlZddlmZddlmZmZmZddl	Z	ddl
Z
dd�ZGdd�d�ZGdd	�d	�Z
ejjd
ejejejejg�ejjddd
g�ejjdejjejjejjejjejjejjg�dd����ZGdd�d�ZdS)�N)�random)�assert_array_equal�
assert_raises�assert_allclosecCsRt|�}dtjtj|�t|�}tj|�jdd�|}tj|tj|�dd�S)Ny@�)�axisy�����)�len�np�piZarange�floatZreshape�sum�exp)�x�L�phase�r�?/tmp/pip-build-5_djhm0z/numpy/numpy/fft/tests/test_pocketfft.py�fft1src@seZdZdd�ZdS)�TestFFTShiftcCstttjjdddgd�dS)Nr��r)r�
ValueErrorr
�fft)�selfrrr�
test_fft_nszTestFFTShift.test_fft_nN)�__name__�
__module__�__qualname__rrrrrrsrc@s�eZdZdd�Zdd�Zejjdd*�dd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zejjd"ejjejjejjejjg�d#d$��Zd%d&�Zejjd'ejejejej g�d(d)��Z!dS)+�	TestFFT1DcCs�d}t|�dt|�}t|�}xptd|�D]b}ttjjtjj|d|���|d|�dd�ttjjtjj|d|��|�|d|�dd�q,WdS)Niy�?rrg�-���q=)�atol)r�rangerr
r�ifft�irfft�rfft)r�maxlenrZxr�irrr�
test_identitys&zTestFFT1D.test_identitycCsZtd�dtd�}tt|�tjj|�dd�tt|�tjd�tjj|dd�dd�dS)N�y�?g���ư>)r �ortho)�norm)rrrr
r�sqrt)rrrrr�test_fft$szTestFFT1D.test_fftr*Nr)cCshtd�dtd�}t|tjjtjj||d�|d�dd�tjtdd��tjjg|d�WdQRXdS)Nr(y�?)r*g���ư>)r z!Invalid number of FFT data points)�match)rrr
rr"�pytestZraisesr)rr*rrrr�	test_ifft*s
zTestFFT1D.test_ifftcCsrtd�dtd�}ttjjtjj|dd�dd�tjj|�dd�ttjj|�tjd
�tjj|d	d
�dd�dS)Nr(�y�?r)rrg���ư>)r r))r*)r(r0)r(r0iX)rrr
r�fft2r+)rrrrr�	test_fft25s
zTestFFT1D.test_fft2cCsrtd�dtd�}ttjjtjj|dd�dd�tjj|�dd�ttjj|�tjd
�tjj|d	d
�dd�dS)Nr(r0y�?r)rrg���ư>)r r))r*)r(r0)r(r0iX)rrr
rr"�ifft2r+)rrrrr�
test_ifft2<s
zTestFFT1D.test_ifft2cCs~td
�dtd�}ttjjtjjtjj|dd�dd�dd�tjj|�d	d
�ttjj|�tjd�tjj|dd�d	d
�dS)Nr(r0�
y�?r)rrrg���ư>)r r))r*)r(r0r5)r(r0r5iXip)rrr
r�fftnr+)rrrrr�	test_fftnCs&zTestFFT1D.test_fftncCs~td
�dtd�}ttjjtjjtjj|dd�dd�dd�tjj|�d	d
�ttjj|�tjd�tjj|dd�d	d
�dS)Nr(r0r5y�?r)rrrg���ư>)r r))r*)r(r0r5)r(r0r5iXip)rrr
rr"�ifftnr+)rrrrr�
test_ifftnKs&zTestFFT1D.test_ifftnc	Cs�td�}x�|jd|jgD]~}xFd	D]>}ttjj|||d�d|dd�tjj|||d�dd�q$Wttjj||d�tj|�tjj||dd�dd�qWdS)
Nr(rr))�nr*rg���ư>)r )r:)Nr))r�sizerr
rr$r+)rrr:r*rrr�	test_rfftSs
 zTestFFT1D.test_rfftcCsPtd�}t|tjjtjj|��dd�t|tjjtjj|dd�dd�dd�dS)Nr(g���ư>)r r))r*)rrr
rr#r$)rrrrr�
test_irfft^szTestFFT1D.test_irfftcCsftd�}ttjj|�dd�dd�ftjj|�dd�ttjj|�tjd	�tjj|dd�dd�dS)
Nr(r0�g���ư>)r r))r*)r(r0iX)rrr
rr1�rfft2r+)rrrrr�
test_rfft2ds.zTestFFT1D.test_rfft2cCsPtd�}t|tjjtjj|��dd�t|tjjtjj|dd�dd�dd�dS)Nr(r0g���ư>)r r))r*)r(r0)rrr
rZirfft2r?)rrrrr�test_irfft2jszTestFFT1D.test_irfft2cCsltd	�}ttjj|�dd�dd�dd�ftjj|�dd�ttjj|�tjd�tjj|dd�dd�dS)Nr(r0r5�g���ư>)r r))r*)r(r0r5iXip)rrr
rr6�rfftnr+)rrrrr�
test_rfftnps4zTestFFT1D.test_rfftncCsPtd�}t|tjjtjj|��dd�t|tjjtjj|dd�dd�dd�dS)	Nr(r0r5g���ư>)r r))r*)r(r0r5)rrr
r�irfftnrC)rrrrr�test_irfftnvszTestFFT1D.test_irfftncCs�td�dtd�}tjtd�|td�f�}tj||ddd	�j�f�}ttjj|�tjj|�dd�ttjj|�tjd�tjj|dd�dd�dS)
N�y�?rg���ư>)r r(r))r*r)rr
�concatenate�conjrr�hfftr+)rr�x_hermrrr�	test_hfft|szTestFFT1D.test_hfftcCs�td�dtd�}tjtd�|td�f�}tj||ddd�j�f�}t|tjjtjj|��dd�t|tjjtjj|dd�dd�dd�dS)	NrGy�?rg���ư>)r r))r*r)rr
rHrIrr�ihfftrJ)rrrKrrr�
test_ihttf�szTestFFT1D.test_ihttf�opcCs\td
�}ddd
dddg}x>|D]6}|tj||��}tj|||d�|�}t||dd	�qWdS)Nr(r0r5rrr)�axesg���ư>)r )r(r0r5)rrr)rrr)rrr)rrr)rrr)rrr)rr
Z	transposer)rrOrrP�aZop_trZtr_oprrr�	test_axes�s
zTestFFT1D.test_axesc	Cs�td�}tjj|�}|jd}tjjtjjftjjtjjftjj	tjj
fg}xj|D]b\}}xX|jd|jgD]D}x>dD]6}||||d�}||||d�}t|tjj|�dd�qvWqlWqRWdS)Nr(rr))r:r*g���ư>)r )Nr))rr
Zlinalgr*r;rr"r$r#rMrJr)	rrZx_normr:Z
func_pairsZforw�backr*�tmprrr�test_all_1d_norm_preserving�s

z%TestFFT1D.test_all_1d_norm_preserving�dtypecCsNtd�j|�}ttjjtjj|��|dd�ttjjtjj|��|dd�dS)Nr(g���ư>)r )r�astyperr
rr"r#r$)rrVrrrr�test_dtypes�szTestFFT1D.test_dtypes)Nr))"rrrr'r,r.�mark�parametrizer/r2r4r7r9r<r=r@rArDrFrLrNr
rr6r8rCrErRrUZhalfZsingle�doubleZ
longdoublerXrrrrrs(
		rrV�order�Fznon-contiguousrcCsBtjjd�}|jddd�j|dd�}dtjtj|j��tj|j	�j
}|dkr\tj|�}n"|ddd�}tj|ddd��}|j
jd
�r�x�td�D],}|||d�}|||d�}	t||	||d
�q�Wnx|j
jd��r8dddg}
|j
jd��r�|
jddddg�x>|
D].}|||d�}|||d�}	t||	||d
��qWnt��dS)N�*���
F)�copyg @r]rrr)r)r Zrtolr1r6rr)rPrr)r1r6)rr)rr)rr)r)r)r)r
rZRandomStateZrandrWr+�log2r;ZfinforVZepsZasfortranarrayZascontiguousarrayr�endswithr!r�extendr)rVr\r�rng�XZ_tol�YrZX_resZY_resrPZaxrrr�test_fft_with_order�s*$

ric@s<eZdZdZdZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�TestFFTThreadSafe�� ��cs��fdd��tj�����}���fdd�t|j�D�}dd�|D�dd�|D�x&t|j�D]}t�jdd�|d	�q`WdS)
Ncs|j�|��dS)N)�put)�args�q)�funcrr�worker�sz.TestFFTThreadSafe._test_mtsame.<locals>.workercsg|]}tj���fd��qS))�targetro)�	threading�Thread)�.0r&)rorprrrr�
<listcomp>�sz2TestFFTThreadSafe._test_mtsame.<locals>.<listcomp>cSsg|]}|j��qSr)�start)rvrrrrrw�scSsg|]}|j��qSr)�join)rvrrrrrw�s�)�timeoutz6Function returned wrong value in multithreaded context)�queue�Queuer!�threadsr�get)rrqro�expected�tr&r)rorqrprrr�_test_mtsame�szTestFFTThreadSafe._test_mtsamecCs(tj|j�dd}|jtjj|�dS)Nry)r
�ones�input_shaper�r)rrQrrrr,�szTestFFTThreadSafe.test_fftcCs(tj|j�dd}|jtjj|�dS)Nry)r
r�r�r�rr")rrQrrrr/�szTestFFTThreadSafe.test_ifftcCs tj|j�}|jtjj|�dS)N)r
r�r�r�rr$)rrQrrrr<�szTestFFTThreadSafe.test_rfftcCs(tj|j�dd}|jtjj|�dS)Nry)r
r�r�r�rr#)rrQrrrr=�szTestFFTThreadSafe.test_irfftN)rlrm)
rrrr~r�r�r,r/r<r=rrrrrj�srj)Znumpyr
r.Znumpy.randomrZ
numpy.testingrrrrtr|rrrrYrZZfloat32Zfloat64Z	complex64Z
complex128rr1r6r"r3r8rirjrrrr�<module>s$$