3
Odv&                 @   s   d dl mZmZ d dlmZmZ d dlmZ d dlZd dl	Z
d dlZddddd	d
dddddgZdd Zdd ZG dd deZG dd deZdS )    )next_fast_len_init_nd_shape_and_axes)assert_equalassert_array_equal)raisesN                  	   
   c              C   s    xt D ]} tt| |  qW d S )N)_5_smooth_numbersr   r   )n r   O/var/www/html/virt/lib64/python3.6/site-packages/scipy/fft/tests/test_helper.pytest_next_fast_len   s    
r   c             C   s   | }|dk rdst x t| d\}}|dkr.P |} qW x:td|d dD ]&}x t| |\}}|dkrfP |} qNW qHW | dkst dj||| d S )Nr   Fr   r      z#x={} is not {}-smooth, remainder={})AssertionErrordivmodrangeformat)xr   Zx_origqrdr   r   r   _assert_n_smooth   s     
r   c               @   sN   e Zd Zdd Zdd Zdd Zejje	j
dk d	ed
ddd Zdd ZdS )TestNextFastLenc             C   s`   t jjd dd }xF| D ]<}t|}t|d |t|dksDtt|d}t|d qW d S )Ni  c              s   s$   xt ddD ]
} | V  qW dV  d S )Nr   i  r   r
   r   r	          i`  i   i y iy )r   )jr   r   r   nums/   s    
z0TestNextFastLen.test_next_fast_len.<locals>.nums   FTr
   )nprandomseedr   r   r   )selfr"   r   mr   r   r   r   ,   s    

z"TestNextFastLen.test_next_fast_lenc             C   sP   t jt jt jt jt jt jg}x.|D ]&}|d}t|}t|tt	| q"W d S )Ni90  )
r$   Zint16Zint32Zint64Zuint16Zuint32Zuint64r   r   int)r'   ZITYPESZitypr   ZtestNr   r   r   test_np_integers<   s
    
z TestNextFastLen.test_np_integersc             C   sN   ddddddddddd	d
dddd}x$|j  D ]\}}tt|d| q.W d S )Nr   r   r   r	   r
   r   r            i   i   i @)r   r   r   r	   r
   r      r      r+   r,      i  i   i @T)itemsr   r   )r'   hamsr   yr   r   r   testnext_fast_len_smallC   s    z'TestNextFastLen.testnext_fast_len_smallr   r   z$Hamming Numbers too large for 32-bitT)reasonr   strictc          8   C   s   ddddddddddddddd	d	dd
ddddddddddd dddd!dddd"dddd#dddd$dddd%dd&dddd'di}x$|j  D ]\}}tt|d| q~W d S )(Nihr   i i=ui+2i  B3l      l   s' l   >9l         l      fn l    >Uko l     q. l   xQ+t0 l      ! l    dopL? l   hRl   2 f;l          l     `71Y!l    ("l           l    X l         	 Tihi,2l     l   >9l     fn l    q. l     ! l   hRl   2 f;l   l    `71Y!l          l   X l   !X )r1   r   r   )r'   r2   r   r3   r   r   r   testnext_fast_len_bigK   s4    z%TestNextFastLen.testnext_fast_len_bigc             C   s,   t ddddkstt ddddks(td S )Nr#   T)real   r.   F)targetr8   )r   r   )r'   r   r   r   test_keyword_argsp   s    z!TestNextFastLen.test_keyword_argsNl        )__name__
__module____qualname__r   r*   r4   pytestmarkZxfailsysmaxsize
ValueErrorr7   r;   r   r   r   r   r   *   s   #r   c               @   sl   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )Test_init_nd_shape_and_axesc             C   sN   t jd}d }d }t jg }t jg }t|||\}}t|| t|| d S )Nr	   )r$   arrayr   r   )r'   r   shapeaxesshape_expectedaxes_expected	shape_resaxes_resr   r   r   test_py_0d_defaultsw   s    



z/Test_init_nd_shape_and_axes.test_py_0d_defaultsc             C   sN   t jd}d }d }t jg }t jg }t|||\}}t|| t|| d S )Ng      @)r$   rE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_0d_defaults   s    



z/Test_init_nd_shape_and_axes.test_np_0d_defaultsc             C   sX   t jdddg}d }d }t jdg}t jdg}t|||\}}t|| t|| d S )Nr   r   r   r   )r$   rE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_py_1d_defaults   s    
z/Test_init_nd_shape_and_axes.test_py_1d_defaultsc             C   sV   t jddd}d }d }t jdg}t jdg}t|||\}}t|| t|| d S )Nr   r   g?r   )r$   arangerE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_1d_defaults   s    
z/Test_init_nd_shape_and_axes.test_np_1d_defaultsc             C   sj   t jddddgddddgg}d }d }t jddg}t jd	dg}t|||\}}t|| t|| d S )
Nr   r   r   r	   r
   r   r.   r   r   )r$   rE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_py_2d_defaults   s    
z/Test_init_nd_shape_and_axes.test_py_2d_defaultsc             C   sb   t jdddjdd}d }d }t jddg}t jddg}t|||\}}t|| t|| d S )Nr   r   g?r
   r   )r$   rO   ZreshaperE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_2d_defaults   s    
z/Test_init_nd_shape_and_axes.test_np_2d_defaultsc             C   sl   t jdddddg}d }d }t jdddddg}t jdddddg}t|||\}}t|| t|| d S )Nr   r   r
   r   r	   r   r   )r$   zerosrE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_5d_defaults   s    
z/Test_init_nd_shape_and_axes.test_np_5d_defaultsc             C   sv   t jdddddg}dd	d
ddg}d }t jdddddg}t jdddddg}t|||\}}t|| t|| d S )Nr   r   r
   r   r	   r   r   r   rU   )r$   rS   rE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_5d_set_shape   s    
z0Test_init_nd_shape_and_axes.test_np_5d_set_shapec             C   sj   t jdddddg}d }dddg}t jdddg}t jdddg}t|||\}}t|| t|| d S )Nr   r   r
   r   r	   r   )r$   rS   rE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_5d_set_axes   s    

z/Test_init_nd_shape_and_axes.test_np_5d_set_axesc             C   sp   t jdddddg}dd	dg}dddg}t jdddg}t jdddg}t|||\}}t|| t|| d S )
Nr   r   r
   r   r	   r   r   r   rU   )r$   rS   rE   r   r   )r'   r   rF   rG   rH   rI   rJ   rK   r   r   r   test_np_5d_set_shape_axes   s    


z5Test_init_nd_shape_and_axes.test_np_5d_set_shape_axesc             C   s@   t jd}t|dd d\}}t|dddg t|dddg d S )	Nr   r   r	   r
   )rF   rG   r   )r   r   r	   r
   )r
   r
   r
   )r$   rS   r   r   )r'   r   rF   rG   r   r   r   test_shape_axes_subset   s    
z2Test_init_nd_shape_and_axes.test_shape_axes_subsetc          K   C   s  t jd}ttdd  t|d ddgddggd W d Q R X ttdd t|d dd	d
dgd W d Q R X ttdd t|d dgd W d Q R X ttdd t|d dgd W d Q R X ttdd t|d ddgd W d Q R X ttdd  t|ddgddggd d W d Q R X ttdd t|dd	d
dgd d W d Q R X ttdd* tt jddddgdddgdgd W d Q R X ttdd t|dgd d W d Q R X ttdd t|dd d W d Q R X d S )Nr   z-axes must be a scalar or iterable of integers)matchr   r   r	   )rF   rG   g      ?g       @g      @g      @z$axes exceeds dimensionality of inputzall axes must be uniquer   z.shape must be a scalar or iterable of integerszBwhen given, axes and shape arguments have to be of the same lengthz1invalid number of data points \(\[0\]\) specifiedz2invalid number of data points \(\[-2\]\) specifiedr[   )r$   rS   assert_raisesrC   r   )r'   r   r   r   r   test_errors  s8    
$ 


$ 


z'Test_init_nd_shape_and_axes.test_errorsN)r<   r=   r>   rL   rM   rN   rP   rQ   rR   rT   rV   rW   rX   rY   r]   r   r   r   r   rD   u   s   rD   r      r   r    i  r            i  )Zscipy.fft._helperr   r   Znumpy.testingr   r   r?   r   r\   Znumpyr$   rA   r   r   r   objectr   rD   r   r   r   r   <module>   s   K