
    xf!                     X   d dl mZmZmZmZmZmZ d dlZd dlmZ	 d dl
mZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZmZmZmZmZmZm Z m!Z! d dlZ"d dl#Zd dl$m%Z% g dZ&g dZ'd	gZ(d
gZ)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3 G d d      Z4 G d de4      Z5 G d de4      Z6 G d de4      Z7 G d d      Z8 G d d       Z9ejt                  jw                  e"jx                  e"jz                  u d!"       G d# d$e9             Z> G d% d&e9      Z? G d' d(e9      Z@ G d) d*      ZAejt                  jw                  e"j                  e"jz                  u d!"       G d+ d,eA             ZC G d- d.eA      ZD G d/ d0eA      ZE G d1 d2      ZFejt                  jw                  e"j                  e"jz                  u d!"       G d3 d4eF             ZG G d5 d6eF      ZH G d7 d8eF      ZI G d9 d:      ZJ G d; d<      ZK G d= d>      ZL G d? d@      ZM G dA dB      ZN G dC dD      ZO G dE dF      ZP G dG dH      ZQejt                  j                  dIeeeeeeeeg      dJ        ZSejt                  j                  dIeeeeeeeeg      dK        ZTejt                  j                  dIeeeeg      dL        ZUy)M    )assert_assert_equalassert_array_almost_equalassert_array_almost_equal_nulpassert_array_lessassert_allcloseN)raises)ifftfftfftnifftnrfftirfftrfftnirfftnfft2hfftihffthfftnihfftn)	arangearrayasarrayzerosdotexppiswapaxescdoublerand)i    i`  i  )      $   i     c                     d| d| }t        t        j                  j                  | |z
        |t        j                  j                  |       z  |       y )Nzsize: z  rdt: )r   nplinalgnorm)xyrtolsizerdterr_msgs         G/usr/lib/python3/dist-packages/scipy/fft/_pocketfft/tests/test_basic.py_assert_close_in_normr1   &   sC    tfGC5)GbiinnQU+T"))..2C-CWM    c                     t        |  S Nr    )r-   s    r0   randomr5   ,   s    ;r2   c                 Z    | j                   j                  d      }| j                  |      S )z-Returns the same array with swapped byteorderS)dtypenewbyteorderastype)arrr8   s     r0   swap_byteorderr<   /   s%    II""3'E::er2   c                     t        |       } t        |       }t        |t              }t	        |       dt
        z  |z  z  }t        |      D ]  }t        t        ||z        |       ||<    |S Nr8                  @	r   lenr   r   r   r   ranger   r   r*   nr+   wis        r0   
direct_dftrH   4   sh    
AAAawA	
BrE!GA1X  3qs8Q! Hr2   c                     t        |       } t        |       }t        |t              }t	        |      dt
        z  |z  z  }t        |      D ]   }t        t        ||z        |       |z  ||<   " |S r>   rA   rD   s        r0   direct_idftrJ   >   sk    
AAAawAq	2b57A1X "3qs8Q!!"Hr2   c                 j    t        |       } t        | j                        D ]  }t        | |      }  | S N)axis)r   rC   ndimr   r*   rM   s     r0   direct_dftnrP   H   s3    
Aaff Hr2   c                 j    t        |       } t        | j                        D ]  }t        | |      }  | S rL   )r   rC   rN   r
   rO   s     r0   direct_idftnrR   O   s3    
Aaff Hr2   c                     t        |       } t        |       }t        |       dt        z  |z  z  }t	        |dz  dz   t
              }t        |dz  dz         D ]  }t        t        ||z        |       ||<    |S )Nr@   r"      r?   )	r   rB   r   r   r   r   rC   r   r   )r*   rE   rF   r+   rG   s        r0   direct_rdftrU   V   sx    
AAA	
BrE!GAad1fG$A1a46]  3qs8Q! Hr2   c                     t        |       } t        |t              }t        |dz  dz         D ]7  }| |   ||<   |dkD  sd|z  |k  st	        j
                  | |         |||z
  <   9 t        |      j                  S )Nr?   r"   rT   r   )r   r   r   rC   r'   conjrJ   real)r*   rE   x1rG   s       r0   direct_irdftrZ   `   s{    
A	q	 B1a46] $!1q5QqS1WggadmBqsG$ r?r2   c                 Z    t        t        |       t        | j                  dz
              S )NrT   axes)r   r   rC   rN   r*   s    r0   direct_rdftnr_   j   s     QeAFFQJ/00r2   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)_TestFFTBasec                 ^    d | _         d | _        t        j                  j	                  d       y N  )cdtr.   r'   r5   seedselfs    r0   setup_methodz_TestFFTBase.setup_methodo   s     
		tr2   c                 P   t        j                  g d| j                        }t        |      }t	        |j
                  | j                         t        |      }t        ||       t        j                  g d| j                        }t        t        |      t        |             y )NrT   r"            @      ?rT   r"   rl   y      @       @r?   rT   r"   rl   y      @           )r'   r   re   r   r   r8   rH   r   rh   r*   r+   y1s       r0   test_definitionz_TestFFTBase.test_definitiont   sk    HH,DHH=FQWWdhh']!!B'HH^4884!#a&A7r2   c                 z   t        j                  g d| j                        }t        j                  g d| j                        }t        ||gd      }t	        |j
                  | j                         t	        |j                  d       t        |d   t        |             t        |d   t        |             y NrT   r"   rl      r?   rv   rE   r"   rv   r   rT   )
r'   r   r.   r   r   r8   re   shaper   rH   rh   rY   x2r+   s       r0   test_n_argument_realz!_TestFFTBase.test_n_argument_real}   s~    XXitxx0XXitxx0B!QWWdhh'QWWU#!!A$z"~6!!A$z"~6r2   c                 z   t        j                  g d| j                        }t        j                  g d| j                        }t        ||gd      }t	        |j
                  | j                         t	        |j                  d       t        |d   t        |             t        |d   t        |             y )N)rT   r"   rl   rm   r?   rv   rw   rx   r   rT   )	r'   r   re   r   r   r8   ry   r   rH   rz   s       r0   _test_n_argument_complexz%_TestFFTBase._test_n_argument_complex   s~    XXl$((3XXl$((3B!QWWdhh'QWWU#!!A$z"~6!!A$z"~6r2   c                    t        dd      D ]|  }d|z  }t        j                  |      }t        |j	                  t
                    }t        j                  j                  |      }t        ||       t        |      }t        ||       ~ y Nr"      )rC   r'   r   r   r:   complexnumpyr   rh   rG   rE   r*   r+   y2s         r0   test_djbfftz_TestFFTBase.test_djbfft   so    q 	,A1A		!AAHHW%&Aq!B%a+AA%a+	,r2   c                 f    t        t        t        g        t        t        t        ddgddggd       y NrT   r"   )assert_raises
ValueErrorr   rg   s    r0   test_invalid_sizesz_TestFFTBase.test_invalid_sizes   s(    j#r*j#1qe}b9r2   N)	__name__
__module____qualname__ri   rr   r|   r~   r   r    r2   r0   ra   ra   n   s     
877,:r2   ra   c                       e Zd Zd Zy)TestLongDoubleFFTc                 X    t         j                  | _        t         j                  | _        y r4   )r'   longcomplexre   
longdoubler.   rg   s    r0   ri   zTestLongDoubleFFT.setup_method   s    >>==r2   Nr   r   r   ri   r   r2   r0   r   r      s    !r2   r   c                       e Zd Zd Zy)TestDoubleFFTc                 X    t         j                  | _        t         j                  | _        y r4   r'   r   re   doubler.   rg   s    r0   ri   zTestDoubleFFT.setup_method       ::99r2   Nr   r   r2   r0   r   r          r2   r   c                       e Zd Zd Zy)TestSingleFFTc                 X    t         j                  | _        t         j                  | _        y r4   r'   	complex64re   float32r.   rg   s    r0   ri   zTestSingleFFT.setup_method       <<::r2   Nr   r   r2   r0   r   r          r2   r   c                       e Zd Zd Zd Zy)TestFloat16FFTc                 D   t        j                  g dt         j                        }t        |d      }t	        |j
                  t         j                         t	        |j                  d       t        |t        |j                  t         j                                     y )Nru   r?   rv   rw   )rv   r'   r   float16r   r   r8   r   ry   r   rH   r:   r   )rh   rY   r+   s      r0   test_1_argument_realz#TestFloat16FFT.test_1_argument_real   s]    XXl"**5aLQWWbll+QWWe$!!Z		"**0E%FGr2   c                    t        j                  g dt         j                        }t        j                  g dt         j                        }t        ||gd      }t	        |j
                  t         j                         t	        |j                  d       t        |d   t        |j                  t         j                                     t        |d   t        |j                  t         j                                     y rt   r   rz   s       r0   r|   z#TestFloat16FFT.test_n_argument_real   s    XXl"**5XXl"**5RAQWWbll+QWWf%!!A$
299RZZ3H(IJ!!A$
299RZZ3H(IJr2   N)r   r   r   r   r|   r   r2   r0   r   r      s    HKr2   r   c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
_TestIFFTBasec                 B    t         j                  j                  d       y rc   r'   r5   rf   rg   s    r0   ri   z_TestIFFTBase.setup_method       
		tr2   c                 L   t        j                  g d| j                        }t        |      }t	        |      }t        |j                  | j                         t        ||       t        j                  g d| j                        }t        t        |      t	        |             y )Nrk   rn   )r'   r   re   r
   rJ   r   r8   r   rp   s       r0   rr   z_TestIFFTBase.test_definition   sk    HH,dhh7G^QWWdhh'!!B'HH^TXX.!$q'+a.9r2   c                    t        j                  g d| j                        }t        |      }t	        |j
                  | j                         t        |      }t        ||       t        j                  g d| j                        }t	        |j
                  | j                         t        t        |      t        |             y )NrT   r"   rl   rv   rT   r"   rl   rv   rT   r"   rl   rv   ro   r?   )	r'   r   r.   r
   r   r8   re   rJ   r   rp   s       r0   test_definition_realz"_TestIFFTBase.test_definition_real   s}    HH&1GQWWdhh'^!!B'HH[1QWWdhh'!$q'+a.9r2   c                    t        dd      D ]  }d|z  }t        j                  |      }t        |j	                  | j
                              }t        j                  j                  |      }t        ||| j                  | j                         t        |      }t        ||| j                  | j                          y )Nr"   r   )r,   atol)rC   r'   r   r
   r:   re   r   r   r   r,   r   r   s         r0   r   z_TestIFFTBase.test_djbfft   s    q 	BA1A		!AQXXdhh'(A"BAbtyytyyAQAAbtyytyyA	Br2   c                    dD ]  }t        |g      j                  | j                        }t        |g      j                  | j                        d|z  z   }t        t	        |            }t	        t        |            }t        |j                  | j                         t        |j                  | j                         t        ||       t        ||        y )N	rT   3   o   d      @         i                 ?)r5   r:   re   r
   r   r   r8   r   rh   r-   r*   rq   r   s        r0   test_random_complexz!_TestIFFTBase.test_random_complex   s    6 	-Dv%%dhh/Av%%dhh/"Q$6Ac!fBT!WB488,488,%b!,%b!,	-r2   c                 \   dD ]  }t        |g      j                  | j                        }t        t	        |            }t	        t        |            }t        |j                  | j                         t        |j                  | j                         t        ||       t        ||        y )Nr   )	r5   r:   r.   r
   r   r   r8   re   r   r   s        r0   test_random_realz_TestIFFTBase.test_random_real   s}    6 	-Dv%%dhh/Ac!fBT!WB488,488,%b!,%b!,	-r2   c                    t         t        z   D ]t  }t        j                  j	                  d       t        j                  j                  |      j                  | j                        }t        t        |            }t        ||| j                  || j                         t        t        |            }t        ||| j                  || j                         |dt        j                  j                  |      z  z   j                  | j                        }t        t        |            }t        ||| j                  || j                         t        t        |            }t        ||| j                  || j                         w y )Nrd   r   )LARGE_COMPOSITE_SIZESLARGE_PRIME_SIZESr'   r5   rf   r!   r:   r.   r
   r   r1   r,   re   )rh   r-   r*   r+   s       r0   test_size_accuracyz _TestIFFTBase.test_size_accuracy   s	   ),== 	CDIINN4 		t$++DHH5ASVA!!Q		4BDGA!!Q		4BR		t,,,44TXX>ASVA!!Q		4BDGA!!Q		4B	Cr2   c                 f    t        t        t        g        t        t        t        ddgddggd       y r   )r   r   r
   rg   s    r0   r   z _TestIFFTBase.test_invalid_sizes  (    j$+j$!A!ur:r2   N)r   r   r   ri   rr   r   r   r   r   r   r   r   r2   r0   r   r      s,    :	:B	--C ;r2   r   z Long double is aliased to double)reasonc                       e Zd Zd Zy)TestLongDoubleIFFTc                 t    t         j                  | _        t         j                  | _        d| _        d| _        y N绽|=)r'   r   re   r   r.   r,   r   rg   s    r0   ri   zTestLongDoubleIFFT.setup_method  s&    >>==		r2   Nr   r   r2   r0   r   r     s    r2   r   c                       e Zd Zd Zy)TestDoubleIFFTc                 t    t         j                  | _        t         j                  | _        d| _        d| _        y r   )r'   r   re   r   r.   r,   r   rg   s    r0   ri   zTestDoubleIFFT.setup_method  s&    ::99		r2   Nr   r   r2   r0   r   r     s    r2   r   c                       e Zd Zd Zy)TestSingleIFFTc                 t    t         j                  | _        t         j                  | _        d| _        d| _        y )Nh㈵>g-C6?)r'   r   re   r   r.   r,   r   rg   s    r0   ri   zTestSingleIFFT.setup_method#  s&    <<::		r2   Nr   r   r2   r0   r   r   "  s    r2   r   c                   D    e Zd Zd Zd Zd Zd Zd Z G d d      Zd Z	y	)
_TestRFFTBasec                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   z_TestRFFTBase.setup_method+  r   r2   c                     g dg dfD ]e  }t        j                  || j                        }t        |      }t	        |      }t        ||       t        |j                  | j                         g y )Nr   )	rT   r"   rl   rv   rT   r"   rl   rv   ro   r?   )	r'   r   r.   r   rU   r   r   r8   re   )rh   tr*   r+   rq   s        r0   rr   z_TestRFFTBase.test_definition.  sY    *,GH 	,A$((+AQAQB%a+$((+	,r2   c                     t        dd      D ]R  }d|z  }t        j                  |      }t        j                  j	                  |      }t	        |      }t        ||       T y r   )rC   r'   r   r   r   r   rh   rG   rE   r*   rq   r+   s         r0   r   z_TestRFFTBase.test_djbfft6  sQ    q 	,A1A		!AQBQA%a+	,r2   c                 f    t        t        t        g        t        t        t        ddgddggd       y r   )r   r   r   rg   s    r0   r   z _TestRFFTBase.test_invalid_sizes>  r   r2   c                     t        j                  d| j                        }t        t        d      5  t        |       d d d        y # 1 sw Y   y xY w)N
   r?   x must be a real sequencematch)r'   r   re   r   	TypeErrorr   rh   r*   s     r0   test_complex_inputz _TestRFFTBase.test_complex_inputB  s=    HHRtxx(9,GH 	G	 	 	s   AAc                       e Zd Zd Zd Zy)_TestRFFTBase.MockSeriesc                 8    t        j                  |      | _        y r4   )r'   r   datarh   r   s     r0   __init__z!_TestRFFTBase.MockSeries.__init__I  s    

4(DIr2   c                     	 t        | j                  |      S # t        $ r!}t        dj                  |            |d }~ww xY w)Nz-'MockSeries' object has no attribute '{attr}')attr)getattrr   AttributeErrorformat)rh   itemes      r0   __getattr__z$_TestRFFTBase.MockSeries.__getattr__L  sN    @tyy$//! @$ &B&,f$f&79>?@@s    	A=AN)r   r   r   r   r   r   r2   r0   
MockSeriesr   H  s    	)	@r2   r   c                     t        j                  g d      }t        j                  |      }g d}t	        |       t        ||       t        |j                  |       y )N)g      ?g       @g      @g      @g      @r   )r'   r   r   r   r   r   r   )rh   r*   xsexpecteds       r0   test_non_ndarray_with_dtypez)_TestRFFTBase.test_non_ndarray_with_dtypeT  sG    HH)*%%a("R 	Q!RWWh'r2   N)
r   r   r   ri   rr   r   r   r   r   r   r   r2   r0   r   r   *  s,    ,,;
@ 
@	(r2   r   c                       e Zd Zd Zy)TestRFFTLongDoublec                 X    t         j                  | _        t         j                  | _        y r4   )r'   r   re   	longfloatr.   rg   s    r0   ri   zTestRFFTLongDouble.setup_methodb  s    >><<r2   Nr   r   r2   r0   r   r   _  s     r2   r   c                       e Zd Zd Zy)TestRFFTDoublec                 X    t         j                  | _        t         j                  | _        y r4   r   rg   s    r0   ri   zTestRFFTDouble.setup_methodh  r   r2   Nr   r   r2   r0   r  r  g  r   r2   r  c                       e Zd Zd Zy)TestRFFTSinglec                 X    t         j                  | _        t         j                  | _        y r4   r   rg   s    r0   ri   zTestRFFTSingle.setup_methodn  r   r2   Nr   r   r2   r0   r  r  m  r   r2   r  c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)_TestIRFFTBasec                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   z_TestIRFFTBase.setup_methodt  r   r2   c                 `     g d}g d}|d d }g d}|d d } fd} |||        |||       y )N)rT          @      @rm   y      ?       @y      @      @)rT   r  rm   r  rv          @            @      r  ro   )	rT   r  rm   r  y      @      @y      @      r  r  r  c                 L   t        t        j                  | j                        t	        |            }t        | t	        |            }t        |j                  j                         t        ||j                         t        |t        |      j                         y )Nr?   rw   )decimal)r   r'   r   re   rB   rZ   r   r8   r.   r   ndecr
   )r*   xrr+   rq   rh   s       r0   _testz-_TestIRFFTBase.test_definition.<locals>._test~  sh    bhhq1SW=AaR)B$((+%aDII>%aR$))Dr2   r   )rh   rY   x1_1x2_1r{   r  s   `     r0   rr   z_TestIRFFTBase.test_definitionw  sB    $2"1X:"1X	E 	b$b$r2   c                 V   t        dd      D ]  }d|z  }t        j                  d|d      dt        j                  d|dz   d      z  z   }d|d<   |dz  dk(  rt        j                  |d         |d<   t        j                  j                  |      }t        |      }t        ||        y )Nr"   r   r   r   rT   )rC   r'   r   rX   r   r   r   r   s         r0   r   z_TestIRFFTBase.test_djbfft  s    q 	,A1A		"a#b299Q!Q+?&??AAaD1uz""aBaA%a+	,r2   c                    dD ]  }t        |g      j                  | j                        }t        t	        |      |      }t	        t        ||dz  dz
              }t        |j                  | j                         t        |j                  | j                         t        ||| j                  d|z         t        ||| j                  d|z          y )Nr   rw   r"   rT   zsize=%d)r  r/   )
r5   r:   r.   r   r   r   r8   re   r   r  r   s        r0   r   z_TestIRFFTBase.test_random_real  s    6 		ADv%%dhh/AtAw$'BeA$q&(,-B488,488,%b!TYY/84/?A%b!TYY/84/?A		Ar2   c           
      <   | j                   t        j                  k(  rd}n| j                   t        j                  k(  rd}t        t
        z   D ]  }t        j                  j                  d       t        j                  j                  |      j                  | j                         }t        t        |      t        |            }t        |||| j                          t        t        |dt        |      z  dz
              }t        ||||| j                           y )Nr   r   rd   r"   rT   )r.   r'   r   float64r   r   r5   rf   r!   r:   r   r   rB   r1   )rh   r,   r-   r*   r+   s        r0   r   z!_TestIRFFTBase.test_size_accuracy  s    88rzz!DXX#D),== 	>DIINN4 		t$++DHH5Ad1gs1v&A!!QdDHH=U1a#a&j1n-.A!!QdDHH=	>r2   c                 f    t        t        t        g        t        t        t        ddgddggd       y r   )r   r   r   rg   s    r0   r   z!_TestIRFFTBase.test_invalid_sizes  s(    j%,j%1Q%1;r2   N)	r   r   r   ri   rr   r   r   r   r   r   r2   r0   r  r  s  s!    "	,
A><r2   r  c                       e Zd Zd Zy)TestIRFFTLongDoublec                 f    t         j                  | _        t         j                  | _        d| _        y Nr   r'   r   re   r   r.   r  rg   s    r0   ri   z TestIRFFTLongDouble.setup_method      ::99	r2   Nr   r   r2   r0   r  r    s    r2   r  c                       e Zd Zd Zy)TestIRFFTDoublec                 f    t         j                  | _        t         j                  | _        d| _        y r  r  rg   s    r0   ri   zTestIRFFTDouble.setup_method  r   r2   Nr   r   r2   r0   r"  r"    s    r2   r"  c                       e Zd Zd Zy)TestIRFFTSinglec                 f    t         j                  | _        t         j                  | _        d| _        y )Nro   )r'   r   re   r   r.   r  rg   s    r0   ri   zTestIRFFTSingle.setup_method  s    <<::	r2   Nr   r   r2   r0   r%  r%    s    r2   r%  c                       e Zd Zd Zd Zd Zy)Testfft2c                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   zTestfft2.setup_method  r   r2   c                     t        j                  d      }t        |dd      }t         j                  j	                  |dd      }t        ||       y)z-FFT returns wrong result with axes parameter.rv   rv   r"      r-  sr]   N)r   onesr   r   r   r   rh   r*   r+   y_rs       r0   test_regression_244zTestfft2.test_regression_244  sB     JJy!f8,iinnQ&xn8!!S)r2   c                 h    t        t        t        g g       t        t        t        ddgddggd       y )NrT   r"   rv   r/  )r   r   r   rg   s    r0   r   zTestfft2.test_invalid_sizes  s+    j$-j$!Q!Q(8'Br2   N)r   r   r   ri   r6  r   r   r2   r0   r(  r(    s    *Cr2   r(  c                   F   e Zd Zd Zd Zej                  j                  dee	z         d        Z
ej                  j                  deez         d        Zd Zej                  j                  dee	z         d        Zej                  j                  deez         d        Zy	)
TestFftnSinglec                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   zTestFftnSingle.setup_method  r   r2   c                 6   g dg dg dg}t        t        j                  |t        j                              }t	        |j
                  t        j                  k(  d       t        j                  t        |      t        j                        }t        ||       y )NrT   r"   rl   rv   ro         r-  	   z-double precision output with single precision)msg)r   r'   r   r   r   r8   r   r   r4  s       r0   rr   zTestFftnSingle.test_definition  sl     !RZZ()2<<'C	E hhtAw-&q#.r2   r-   c                    t         j                  j                  ||      dt         j                  j                  ||      z  z   }t        |j                  j                  t         j                              }t        |j                  j                  t         j                              j                  t         j                        }t        |j                  t         j                         t        ||d       y )Nr     r'   r5   r!   r   rX   r:   r   r  r   r   r8   r   r   s        r0   test_size_accuracy_smallz'TestFftnSingle.test_size_accuracy_small  s    IINN4&BIINN4,F)FF!&&--

+,!&&--

+,33BLLARXXr||,&r2t4r2   c                    t         j                  j                  |d      dt         j                  j                  |d      z  z   }t        |j                  j                  t         j                              }t        |j                  j                  t         j                              j                  t         j                        }t        |j                  t         j                         t        ||d       y )Nrl   r   rE  rF  r   s        r0   test_size_accuracy_largez'TestFftnSingle.test_size_accuracy_large  s    IINN4#ba)@&@@!&&--

+,!&&--

+,33BLLARXXr||,&r2t4r2   c                 .   g dg dg dg}t        t        j                  |t        j                              }t	        |j
                  t        j                         t        j                  t        |      t        j                        }t        ||       y )Nr=  r>  r@  )r   r'   r   r   r   r8   r   r   r4  s       r0   test_definition_float16z&TestFftnSingle.test_definition_float16   sa     !RZZ()QWWbll+hhtAw-&q#.r2   c                    t         j                  j                  ||      dt         j                  j                  ||      z  z   }t        |j                  j                  t         j                              }t        |j                  j                  t         j                              j                  t         j                        }t        |j                  t         j                         t        ||d       y )Nr   g    Ar'   r5   r!   r   rX   r:   r   r  r   r   r8   r   r   s        r0   test_float16_input_smallz'TestFftnSingle.test_float16_input_small	  s    IINN4&BIINN4,F)FF!&&--

+,!&&--

+,33BLLARXXr||,&r2s3r2   c                    t         j                  j                  |d      dt         j                  j                  |d      z  z   }t        |j                  j                  t         j                              }t        |j                  j                  t         j                              j                  t         j                        }t        |j                  t         j                         t        ||d       y )Nrl   r   g    >ArM  r   s        r0   test_float16_input_largez'TestFftnSingle.test_float16_input_large  s    IINN4#ba)@&@@!&&--

+,!&&--

+,33BLLARXXr||,&r2s3r2   N)r   r   r   ri   rr   pytestmarkparametrizeSMALL_COMPOSITE_SIZESSMALL_PRIME_SIZESrG  r   r   rI  rK  rN  rP  r   r2   r0   r:  r:    s    	/ [[V%:=N%NO5 P5 [[V%:=N%NO5 P5/ [[V%:=N%NO4 P4 [[V%:=N%NO4 P4r2   r:  c                   B    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestFftnc                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   zTestFftn.setup_method  r   r2   c                     g dg dg dg}t        |      }t        |t        |             t        d      }t        t        |      t        |             t        d      }t        t        |      t        |             y )Nr=  r>  r@        ro   rv   rl   r[  )r   r   rP   r5   rh   r*   r+   s      r0   rr   zTestFftn.test_definition   sc     G!![^48!$q';q>:=!!$q';q>:r2   c                 :   g dg dg dg}g dg dg dg}g dg dg d	g}g dg dg dg}g dg dg dg}g dg dg d	g}g d
g dg dg}g dg dg dg}g dg dg dg}	g dg dg dg}
g dg dg dg}g dg dg dg}g dg dg dg}g dg dg dg}g dg dg dg}g d
g dg dg}g dg dg dg}g dg dg dg}|||	g}|
||g}|||g}|||g}|||g}t        |||g      }t        t        |      t        |d             t        t        |      t        |d             t        t        |d      t        |d              t        |d!      }t        t        |d"d#      t        |             t        |d$      }t        t        t        |d"d#      d"d%      t        |             t        |d&      }t        t        t        |d"d#      d#d%      t        |             t        |d'      }t        t        |d%d#      t        |             t        |d(      }t        t        |d%d"      t        |             t        |d)      }t        t        |      |d*          t        t        |      |d+          t        t        |      |d,          t        |d-      }t        t        |      |d*          t        t        |      |d+          t        t        |      |d,          t        |d.      }t        t        |d d d d d*f         |d d d d d*f          t        t        |d d d d d+f         |d d d d d+f          t        t        |d d d d d,f         |d d d d d,f          t        |d/      }t        t        |d d d*d d f         |d d d*d d f          t        t        |d d d+d d f         |d d d+d d f          t        t        |d d d,d d f         |d d d,d d f          t        |d0      }t        t        |      t        |d*   d%d"             t        t        |      t        |d+   d%d"             t        t        |      t        |d,   d%d"             t        |d1      }t        t        |      t        |d d d*d d f   d"d%             t        t        |      t        |d d d+d d f   d"d%             t        t        |      t        |d d d,d d f   d"d%             t        |d2      }t        t        |      t        |d d d d d*f   d"d%             t        t        |      t        |d d d d d+f   d"d%             t        t        |	      t        |d d d d d,f   d"d%             t        |d3      }t	        d4      D ]7  }t	        d4      D ]'  }t        t        |||d d f         |||d d f          ) 9 t        |d5      }t	        d4      D ]7  }t	        d4      D ]'  }t        t        ||d d |f         ||d d |f          ) 9 t        |d6      }t	        d4      D ]7  }t	        d4      D ]'  }t        t        |d d ||f         |d d ||f          ) 9 t        |d7      }t        ||       y )8Nr=  r>  r@  )r         )   r      )         )   r[     )         )   r\     )rT   r   rg  )rv   rb  ri  )rA  rd  rl  )r"   r`  r[  )ro   r   rj  )r-  re  r\  )rl   ra  rh  )r?  rc  rk  )rB  rf  rm  )rT   rv   rA  )r   rb  rd  )rg  ri  rl  )r"   ro   r-  )r`  r   re  )r[  rj  r\  )rl   r?  rB  )ra  rc  rf  )rh  rk  rm  )r/  r0  r  r\   r   rT   r"   )r   r"   )r   r  )r"   rT   r   r  r/  )r"   r   rT   r0  )rT   r"   r   )rT   r   r"   )r   r"   rT   r0  r  r   rT   r"   rT   r"   r.  )r/  r  r  r0  )r  r/  )r0  r/  r  rl   r0  r   r   )r   r   r   r   rC   r   )rh   plane1plane2plane3	ki_plane1	ki_plane2	ki_plane3	jk_plane1	jk_plane2	jk_plane3	kj_plane1	kj_plane2	kj_plane3	ij_plane1	ij_plane2	ij_plane3	ik_plane1	ik_plane2	ik_plane3	ijk_space	ikj_space	jik_space	jki_space	kij_spacer*   r+   rG   js                               r0   test_axes_argumentzTestFftn.test_axes_argument-  s        !!#	 !!#	 !!#	 !  "	 !  "	 !  "	 !<1	!<1	!<1	 	 "!!#	 "!!#	 !  "	 !  "	 !  "	 	95		95		95		95		95	666*+!$q'"&q|"<	>!$q'4	+BC!$qv"6QW8MN#!(1b""5tIG#!(8Ar2+>B"G"&y/	3#!(8Ar2+>B"G"&y/	3#!(1b""5tIG#!(1b""5tIG"!$v,!5!$v,!5!$v,!5 !$v,!5!$v,!5!$v,!5"!$qAqz"2AaAgJ?!$qAqz"2AaAgJ?!$qAqz"2AaAgJ?"!$qAqz"2AaAgJ?!$qAqz"2AaAgJ?!$qAqz"2AaAgJ?"!$y/8AaD"b3IJ!$y/8AaD"b3IJ!$y/8AaD"b3IJ"!$y/"*1Q1W:r2">	@!$y/"*1Q1W:r2">	@!$y/"*1Q1W:r2">	@ "!$y/"*1Q1W:r2">	@!$y/"*1Q1W:r2">	@!$y/"*1Q1W:r2">	@ q 	GA1X G)#a1aj/1Q1W:FG	G q 	GA1X G)#a1aj/1Q1W:FG	G q 	GA1X G)#a1aj/1Q1W:FG	G !!Q'r2   c                     g dg dg}g dg dg dg dg}t        |d      }t        |t        |             t        |d      }t        |t        |d d	              y )
Nr=  r>  rT   r"   rl   r   rv   ro   r?  r   r   r   r   r   rv   rv   r2  )rl   rv   r  )r   r   rh   small_xlarge_x1r+   s       r0   test_shape_argumentzTestFftn.test_shape_argument  s_        "
 F#!!T(^4F#!!T(3B-%89r2   c                     g dg dg dg}t        g dg dg dg dg      }t        |dd	
      }t        |t        |             t        |dd
      }t        |t        t        t        |dd            dd             y )Nr=  r>  r@  r  r  )rA  r-  rB  r   r  r  ro  r1  rq  r  r0  )r   r   r   r   r  s       r0   test_shape_axes_argumentz!TestFftn.test_shape_axes_argument  s     ,&&&( ) F2!!T(^4F2!!X(B+,b"&6 	7r2   c                    t         j                  j                  d      }t        |dd      }t        |t	        |dd             t         j                  j                  d      }t        |dd      }t        |t	        |d	d             t         j                  j                  d
      }t        |dd      }t        |t         j                  j                  |dd             y )N)r   ro   rl   rA  rr  )r-  )r]   r2  r  r-  )rM   rE   rs  r0  r+  r.  r,  )r   r5   r   r   r   r^  s      r0   test_shape_axes_argument2z"TestFftn.test_shape_axes_argument2  s    LL.$'!!Sq%9: LL.$'!!Sq%9: LL	*V,!!"'))..V."L	Nr2   c                     t        d      }t        t        d      5  t        |d       d d d        y # 1 sw Y   y xY w)Nr+  z)shape requires more axes than are presentr   )r-  r-  r"   rT   r  )r   r   r   r   r   s     r0   test_shape_argument_morez!TestFftn.test_shape_argument_more  s9    ):!LN 	$l#	$ 	$ 	$s   4=c                     t        t        d      5  t        g g       d d d        t        t        d      5  t        ddgddggd       d d d        y # 1 sw Y   6xY w# 1 sw Y   y xY wNz4invalid number of data points \(\[1, 0\]\) specifiedr   z5invalid number of data points \(\[4, -3\]\) specifiedrT   r"   r8  )r   r   r   rg   s    r0   r   zTestFftn.test_invalid_sizes  su    :"67 	 "J	
 :"78 	, 1a&1a&!7+	, 	,	 	
	, 	,   AA A A)c                 t    t         j                  j                  d      }t        t        |g       |d       y N)r"   r"   r"   r\   gHz>r   )r   r5   r   r   r   s     r0   test_no_axeszTestFftn.test_no_axes  s)    LL(QR(!$7r2   N)r   r   r   ri   rr   r  r  r  r  r  r   r  r   r2   r0   rW  rW    s2    ;D(L:7N"$	,8r2   rW  c                   T   e Zd ZdZdZd Zej                  j                  de	j                  e	j                  dfe	j                  e	j                  dfg      d        Zej                  j                  dddg      ej                  j                  dg d	      d
               Zd Zd Zy)	TestIfftnNc                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   zTestIfftn.setup_method  r   r2   dtype,cdtype,maxnlprE    c                 Z   t        j                  g dg dg dg|      }t        |      }t        |j                  |       t        |t        |      |       t        d      }t        t        |      t        |      |       t        d      }t        t        |      t        |      |       y Nr=  r>  r@  r?   rZ  r]  )r'   r   r   r   r8   r   rR   r5   rh   r8   cdtypemaxnlpr*   r+   s         r0   rr   zTestIfftn.test_definition       HHi!(-/ !HQWWf%&q,q/6B8&uQxa&I=!&uQxa&Ir2   r  r-   rT   r"   r       r   \   c                     t        ||g      dt        ||g      z  z   }t        t        t        |            ||       t        t        t        |            ||       y )Nr   )r5   r   r   r   )rh   r  r-   r*   s       r0   r   zTestIfftn.test_random_complex  sM     D$< 2fdD\&:#::&uT!W~q&A&tE!H~q&Ar2   c                     t        t        d      5  t        g g       d d d        t        t        d      5  t        ddgddggd       d d d        y # 1 sw Y   6xY w# 1 sw Y   y xY wr  )r   r   r   rg   s    r0   r   zTestIfftn.test_invalid_sizes  su    :"67 	 2$K	
 :"78 	- Aq6Aq6"G,	- 	-	 	
	- 	-r  c                 t    t         j                  j                  d      }t        t        |g       |d       y r  )r   r5   r   r   r   s     r0   r  zTestIfftn.test_no_axes!  s)    LL(ab)148r2   )r   r   r   r8   r  ri   rQ  rR  rS  r'   r  
complex128r   r   rr   r   r   r  r   r2   r0   r  r    s    EF [[2!zz2==$?!zz2<<>@AJAJ [[Xd|4[[V%;<B = 5B
	-9r2   r  c                      e Zd ZdZdZd Zej                  j                  de	j                  e	j                  dfe	j                  e	j                  dfg      d        Zej                  j                  dg d      d	        Zej                  j                  d
eeg      d        Zej                  j                  d
eeg      d        Zd Zy)	TestRfftnNc                 B    t         j                  j                  d       y rc   r   rg   s    r0   ri   zTestRfftn.setup_method)  r   r2   r  rE  r  c                 Z   t        j                  g dg dg dg|      }t        |      }t        |j                  |       t        |t        |      |       t        d      }t        t        |      t        |      |       t        d      }t        t        |      t        |      |       y r  )r'   r   r   r   r8   r   r_   r5   r  s         r0   rr   zTestRfftn.test_definition,  r  r2   r-   r  c                 t    t        ||g      }t        t        t        |      |j                        |d       y )Nr   r  )r5   r   r   r   ry   )rh   r-   r*   s      r0   test_randomzTestRfftn.test_random=  s+    D$< uQx115Ar2   funcc                     t        t        d      5   |g g       d d d        t        t        d      5   |ddgddggd       d d d        y # 1 sw Y   3xY w# 1 sw Y   y xY wr  r   r   rh   r  s     r0   r   zTestRfftn.test_invalid_sizesB  su    :"67 	 "J	
 :"78 	, 1a&1a&!7+	, 	,	 	
	, 	,s   
AAAA#c                 d    t        t        d      5   |g g        d d d        y # 1 sw Y   y xY w)Nz#at least 1 axis must be transformedr   r\   r  r  s     r0   r  zTestRfftn.test_no_axesN  s/    :!FH 	"	 	 	s   &/c                     t        t        d      5  t        t        j                  dt        j
                               d d d        y # 1 sw Y   y xY w)Nr   r   r   r?   )r   r   r   r'   r   r   rg   s    r0   r   zTestRfftn.test_complex_inputT  s9    9,GH 	4"((2R\\23	4 	4 	4s   /A

A)r   r   r   r8   r  ri   rQ  rR  rS  r'   r  r  r   r   rr   r  r   r   r   r  r   r   r2   r0   r  r  %  s    EF [[2!zz2==$?!zz2<<>@AJAJ [[V%;<B =B [[VeV_5	, 6	, [[VeV_5 6
4r2   r  c                       e Zd Zd Zy)	FakeArrayc                 4    || _         |j                  | _        y r4   )_data__array_interface__r   s     r0   r   zFakeArray.__init__Z  s    
#'#;#; r2   N)r   r   r   r   r   r2   r0   r  r  Y  s    <r2   r  c                       e Zd Zd Zd Zy)
FakeArray2c                     || _         y r4   r  r   s     r0   r   zFakeArray2.__init__`  s	    
r2   c                     | j                   S r4   r  rg   s    r0   	__array__zFakeArray2.__array__c  s    zzr2   N)r   r   r   r   r  r   r2   r0   r  r  _  s    r2   r  c                      e Zd ZdZej
                  ej                  ej                  gZeej                  ej                  ej                  gz   Zg dZd Zd Zej"                  j%                  de      ej"                  j%                  de      ej"                  j%                  ddd	g      ej"                  j%                  d
g d      d                             Zej"                  j%                  de      ej"                  j%                  de      ej"                  j%                  ddd	g      ej"                  j%                  d
g d      d                             Zd Zej"                  j%                  de      ej"                  j%                  ddd	g      ej"                  j%                  d
g d      d                      Zy)TestOverwritez4Check input overwrite behavior of the FFT functions.)r-  rd  r  c           	          |j                         }d t        t        fD ]\  } | ||      |||       dj                  |j                  |j
                  |j                  |||      }	|rLt        ||d|	z         ^ y )Nc                     | S r4   r   r^   s    r0   <lambda>z&TestOverwrite._check.<locals>.<lambda>q  s    q r2   )overwrite_xz-{}({}{!r}, {!r}, axis={!r}, overwrite_x={!r})zspurious overwrite in %s)r/   )copyr  r  r   r   r8   ry   r   )
rh   r*   routinefftsizerM   r  should_overwriter{   fakesigs
             r0   _checkzTestOverwrite._checko  sx    VVX )Z8 	NDDHgtEAHH  !''177GT;PC#R,F,LM	Nr2   c                    t         j                  j                  d       t        j                  |t         j                        r=t        j                  j
                  | dt        j                  j
                  | z  z   }nt        j                  j
                  | }|j                  |      }|xr ||v xr |||   k  }	| j                  ||||||	       y )Nrd   r   r  r  )r'   r5   rf   
issubdtypecomplexfloatingrandnr:   r  )
rh   r  r8   ry   rM   overwritable_dtypesr  r  r   r  s
             r0   	_check_1dzTestOverwrite._check_1dy  s    
		t== 2 2399??E*R		0G-GGD99??E*D{{5!' 7 %)< <7 '5; 6 	 	D'7D +%5 	 	7r2   r8   r  r  TFz
shape,axes))rd  r  )rd  r"   r   )r"   rd  rT   c           	          t         j                  t         j                  t         j                  f}| j	                  t
        ||||||       | j	                  t        ||||||       y r4   )r'   r   r  r   r  r   r
   rh   r8   r  r  ry   r]   overwritables          r0   test_fft_ifftzTestOverwrite.test_fft_ifft  sR     r||DsE5$	-tUE4	-r2   c           	          | j                   }| j                  t        ||||||       | j                  t        ||||||       y r4   )real_dtypesr  r   r   r  s          r0   test_rfft_irfftzTestOverwrite.test_rfft_irfft  sE     ''ueUD,	-tUE4	-r2   c                 t  
 t         j                  j                  d       t        j                  t         j                        r=t        j                  j
                  | dt        j                  j
                  | z  z   }nt        j                  j
                  | }|j                        }
fd
d fd} 
 ||            D ]d  }	| j                  |||	| |||	|             |j                  dkD  s2| j                  |j                  ||	| ||j                  |	|             f y )Nrd   r   c              3      K   t        |       dk  rd y | d   dz  | d   | d   dz  fD ]  } | dd        D ]
  }|f|z      y w)Nr   r   r"   rT   )rB   )shpr  restfftshape_iters      r0   r  z2TestOverwrite._check_nd_one.<locals>.fftshape_iter  sg     3x1}a&!)SVSVAX6 *A -c!"g 6 * dTk)**s   AA	c                 H    || S t        t        j                  | |            S r4   )tupler'   take)ry   r]   s     r0   
part_shapez/TestOverwrite._check_nd_one.<locals>.part_shape  s"    |RWWUD122r2   c                      | j                   |      }xr1 t        j                  |      t        j                  |      k  xr v S r4   )ry   r'   prod)r   ry   r]   r2  r8   r  r  r  s       r0   r  z5TestOverwrite._check_nd_one.<locals>.should_overwrite  sF    4::t,A 5GGENbggaj05!446r2   r  rT   )
r'   r5   rf   r  r  r  r:   r  rN   T)rh   r  r8   ry   r]   r  r  r   r  fftshaper  r  s     `  ``   @@r0   _check_nd_onezTestOverwrite._check_nd_one  s   
		t== 2 2399??E*R		0G-GGD99??E*D{{5!	*	3	6 &j&=> 		9HKKgx$/)9$$)O  Q yy1}DFFGXt(3-= $$.8  9		9r2   ))r  N)r  rt  )r  rt  )r  rT   )r-  rd  N)r  r   rT   )r-  rd  r"   r  )r  rp  )r  rt  )r  r  )r  )r"   )r  N)r  rn  c                     t         j                  t         j                  t         j                  f}| j	                  t
        |||||       | j	                  t        |||||       y r4   )r'   r   r  r   r  r   r   )rh   r8   r  ry   r]   r  s         r0   test_fftn_ifftnzTestOverwrite.test_fftn_ifftn  sR      r||D4t\&	(5%l&	(r2   N)r   r   r   __doc__r'   r   r  r   r  r   r  r   dtypesfftsizesr  r  rQ  rR  rS  r  r  r  r  r   r2   r0   r  r  h  s   >::rzz2<<8KBLL"--HHFHN7  [[Wf-[[Y1[[]T5M:[[\ ,: ;-; ; 2 .- [[Wk2[[Y1[[]T5M:[[\ ,: ;-; ; 2 3-&9P [[Wf-[[]T5M:[[\ ,E F(F ; .(r2   r  r  c                     t        j                  dt              }t        t        d      5   | |d       d d d        y # 1 sw Y   y xY w)Nr   r?   zBInvalid norm value 'o', should be "backward", "ortho" or "forward"r   o)r)   )r'   r   floatr   r   )r  r*   s     r0   test_invalid_normr    sF     			"E"A	zA
B  	QS  s   AA
c                     t         j                  j                  d      }|j                  d      d|j                  d      z  z   }t	         | t        |             | |             y )Nrd   r   r   r'   r5   RandomStater!   r   r<   r  rngr*   s      r0   test_swapped_byte_order_complexr    sO     ))


%CrCHHRL((AD*+T!W5r2   c                     t         j                  j                  d      }|j                  d      }t	         | t        |             | |             y )Nrd   r   r  r
  s      r0   test_swapped_byte_order_realr    s;    
))


%CAD*+T!W5r2   )Vnumpy.testingr   r   r   r   r   r   rQ  r	   r   scipy.fft._pocketfftr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   	numpy.fftnumpy.randomr!   r   rT  r   rU  r1   r5   r<   rH   rJ   rP   rR   rU   rZ   r_   ra   r   r   r   r   r   rR  skipifr   r  r   r   r   r   r   r   r  r  r  r  r"  r%  r(  r:  rW  r  r  r  r  r  rS  r  r  r  r   r2   r0   <module>r     s
  , ,  *> > > >& & &    
  	   
N
 1-: -:`! !L L K K&J; J;Z BMMRZZ/=  ? ?] ] 3( 3(j BLLBJJ.=  ?   ? ] ] =< =<F BLLBJJ.=  ?. ?n n C C$:4 :4zX8 X8v,9 ,9\14 14h< < w( w(t #tT5!%ueV"= >> #tT5#(&$"? @6@6 %u!=>6 ?6r2   