a
    Xg O                     @   s   d dl Z d dlZd dl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mZmZ G dd dZG dd dZG dd	 d	ZG d
d dZG dd dZG dd dZdd ZG dd dZdd ZG dd dZ dd Z!dS )    N)assert_assert_equalassert_array_equalassert_almost_equalassert_array_almost_equalassert_raisesassert_raises_regex)mgridogridndenumeratefill_diagonaldiag_indicesdiag_indices_from	index_expndindexr_s_ix_c                   @   sf   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	e
jdg ddd Zdd ZdS )TestRavelUnravelIndexc                 C   s  t tddd t tjdddd tt tjddd W d    n1 sR0    Y  tt tjddd W d    n1 s0    Y  tt tjddd	 W d    n1 s0    Y  tt tjddd
 W d    n1 s0    Y  t tddd t tddd t tddd tttjdd tttjdd tttjdd tttjdd tttjdd tttjdd tttjdd tttjdd t tddg d t tg ddd tg dg dg}t t|dg d t tj|dddg d t tj|ddd g d! t tj|d"d#d g d$ t td%d&d' t ttg ddg dg dg t tjtg ddddg dg dg t td'd&g d% d S )(N   )r   r      r   )indicesshape)r   hape)r      )   ^   )Zims)dims)r   B   g      ?   )r   )r   r   )r   r"   )r   r   )皙?g        .   )r!         )r   r   r!   )r%   r&   r&   )r!      r   )   r&   )   )   %   Forder)   r*      )r!   r&   clipmode)r)         r!   r!   )r1   wrap)   r0   r0   )r%   r   r!   r   )r&   r(      	   iU  )r   npunravel_indexr   	TypeErrorravel_multi_index
ValueErrorarray)selfarr rC   o/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/numpy/lib/tests/test_index_tricks.py
test_basic   sb    
,
,
,
,z TestRavelUnravelIndex.test_basicc                 C   s  d}d}t t|tjg d t t|tjdd t t|tjtg d tttjg tddg g g g t t|tjg g fd t t|tjg dgfd t t|tjtg tg fd tttjg tdtjg tdfdg  tttjg g gtddg  d S )	Nz9indices must be integral: the provided empty sequence waszonly int indices permitted)
   r%   r'   rC   dtyperF   r%   abc)r'   r%   )r   r=   r;   r<   r@   r   intr>   )rA   Zmsg1Zmsg2rC   rC   rD   test_empty_indicesF   s:    
z(TestRavelUnravelIndex.test_empty_indicesc                 C   s   t jt jkrPddgddgddgddgdd	gddgd
dgf}tt |dddg ttt jdd d
gd
gf}t t jj	d }tt ||dfd
g ttt j||d df tt j||dfddd
g ttt j||d dfdd d S )Nr      r%   r'   u   r5   r   iK	  i  r   )r*   r(   x   $   i
  r9   r&   l   z l   nm )l    l       r,   r-   )
r;   intpint64r   r>   r   r?   r<   Ziinfomax)rA   rB   Z	dummy_arrZhalf_maxrC   rC   rD   test_big_indicesZ   s.    
z&TestRavelUnravelIndex.test_big_indicesc                 C   sr  t jt jt jt jt jt jfD ]N}t jg dg dg|d}d}d|d  |d  }tt 	||| t|t 
|| |d d|d   }tt j	||d	d
| t|t j
||d	d
 t jg dg dg dg|d}d}dd|d  |d   |d  }tt 	||| t|t 
|| |d d|d d|d     }tt j	||d	d
| t|t j
||d	d
 qd S )N)r   r   r   r   r%   r!   )r   r&   r   r%   r   r   rG   )r'   r9   r9   r   r   r'   r,   r-   )r   r%   r   r   r:   r'   )r'   r9   rF   rF   r   )r;   Zint16Zuint16Zint32Zuint32rR   Zuint64r@   r   r>   r<   )rA   rH   Zcoordsr   ZuncoordsrC   rC   rD   test_dtypesr   s8    
  z!TestRavelUnravelIndex.test_dtypesc                 C   sd   t tjg ddddtg dd t tjg ddddtg dd tttjg dd d S )N)r'   r   r    r   )r!   r%   r(   r8   r7   r2   )r   r   r&   r   )r7   raiser1   rV   )r   r   r   r   )r   r;   r>   r   r?   rA   rC   rC   rD   test_clipmodes   s    z$TestRavelUnravelIndex.test_clipmodesc                 C   s0   t g dd\}}t|jj t|jj d S )Nr   r   r%   )r!   r'   )r;   r<   r   flagsZ	writeable)rA   xyrC   rC   rD   test_writeability   s    z'TestRavelUnravelIndex.test_writeabilityc                 C   sB   t dd}t|d ttdt jdgd ttdt jdgd d S )Nr   rC   z0d arrayzout of boundsr   )r;   r<   r   r   r?   rA   r[   rC   rC   rD   test_0d   s    
zTestRavelUnravelIndex.test_0dr3   )r1   r7   rV   c                 C   sr   t jt jdt jdd|d}|jdks*J tt, t jt jdt jdd|d W d    n1 sd0    Y  d S )N)r%   r   rG   r   r   r   r2   r   )r%   r   )r;   r>   zerosrQ   r   r   r?   )rA   r3   resrC   rC   rD   test_empty_array_ravel   s    
z,TestRavelUnravelIndex.test_empty_array_ravelc                 C   sx   t t jdt jdd}t|dks(J tdd |D s>J tt t dgd W d    n1 sj0    Y  d S )Nr   rG   r`   r%   c                 s   s   | ]}|j d kV  qdS )ra   N)r   ).0arC   rC   rD   	<genexpr>       zATestRavelUnravelIndex.test_empty_array_unravel.<locals>.<genexpr>r   )r;   r<   rb   rQ   lenallr   r?   )rA   rc   rC   rC   rD   test_empty_array_unravel   s
    
z.TestRavelUnravelIndex.test_empty_array_unravelN)__name__
__module____qualname__rE   rL   rT   rU   rX   r]   r_   pytestmarkparametrizerd   rk   rC   rC   rC   rD   r      s   7	
	r   c                   @   s^   e Zd Zdd Zdd Zdd Zdd Zej	d	d
dgdd Z
dd Zdd Zdd ZdS )TestGridc                 C   s   t ddd }t ddd }t|jdk t|jdk t|d dk t|d d t|d dk t|d |d  dd t|d |d d	 d t|d |d  d
d d S )Nr    r                 $@r#   )rF   )   r      ggfffff?gqq?)r	   r   r   r   )rA   rf   brC   rC   rD   rE      s    zTestGrid.test_basicc                 C   s8   t jdddd\}}t|d t|tddd d d S )Nr   rF   T)Zretstepg9/?y              I@r0   )r;   Zlinspacer   r   r	   )rA   r\   strC   rC   rD   test_linspace_equivalence   s    
z"TestGrid.test_linspace_equivalencec                 C   sV  t ddddddf }t ddddddf }t|jdk t|jd	k t|d
 d
d d f tdd  t|d d d d
f dtdd  t|d
 dd d f tddd t|d d d df dtdd d t|d
dd d f |d
d
d d f  dtdd d t|dd d df |dd d d
f  dtdd d d S )Nr    r   rs   r   r#   g?)r   rF   rF   )r   rt   rt   r   rF   dru   rt   )r	   r   r   r   r;   onesr   )rA   crz   rC   rC   rD   test_nd   s    $&$($$zTestGrid.test_ndc                 C   s\   t ddddddf }tddddddf }tj| }t||D ]\}}t|| qDd S )Nr    r   rs   ry   r   )r	   r
   r;   Zbroadcast_arrayszipr   )rA   Z	grid_fullZgrid_sparseZgrid_broadcastfrv   rC   rC   rD   test_sparse   s
    
zTestGrid.test_sparsezstart, stop, step, expected)NrF   rs   )   rF   )irt   N)i     c                 C   sJ   t ||||||f }t ||| }t|j|d  t|j|d  d S )Nr   r   )r	   r   size)rA   startstopstepexpectedgridZ
grid_smallrC   rC   rD   test_mgrid_size_none_handling   s    	z&TestGrid.test_mgrid_size_none_handlingc                 C   s   t dddf }t tdtdtdf }t|jtjk t|| t ddd }t tdtdtd }t|jtjk t|| d S )Nr#   Q?)r	   r;   float32r   rH   float64r   )rA   grid64Zgrid32rC   rC   rD   test_accepts_npfloating   s    "
 z TestGrid.test_accepts_npfloatingc                 C   s   t dddf }t tdtdtdf }t|jtjk t|| t dtdd }t dtddf }t|j|j  kotjkn   t||d  t ddd }t tdtdtd }t|jtjk t|| d S )Nr#   r   r   r   y        333333@)r	   r;   
longdoubler   rH   r   r   )rA   r   Zgrid128Z
grid128c_aZ
grid128c_brC   rC   rD   test_accepts_longdouble  s     
"z TestGrid.test_accepts_longdoublec                 C   s   t tdddf tddtdf  t tddd tddtd  tddd }tdddf d }t|j|j  kotjkn   t|| tddtd }tddtdf d }t|j|j  kotj	kn   t|| d S )Nr#   g333333?y              @y        ffffff
@r   )
r   r	   r;   	complex64r   rH   r   r   Zclongdoubler   )rA   Zgrid64_aZgrid64_bZ	grid128_aZ	grid128_brC   rC   rD   test_accepts_npcomplexfloating  s    ""
"z'TestGrid.test_accepts_npcomplexfloatingN)rl   rm   rn   rE   rx   r}   r   ro   rp   rq   r   r   r   r   rC   rC   rC   rD   rr      s   	
rr   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestConcatenatorc                 C   sD   t td tg d td}t|dd|f }t |g d 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{   )rA   rv   r|   rC   rC   rD   test_1d/  s    
zTestConcatenator.test_1dc                 C   s"   t dddf }t|jdk d S )Ng333333$@r   rF   f8)r   r   rH   rA   grC   rC   rD   test_mixed_type5  s    z TestConcatenator.test_mixed_typec                 C   s4   t dtdgtg ddf }t|jdk d S )Ng333333$r   )r   r%   r!   g      $@r   )r   r;   r@   r   rH   r   rC   rC   rD   test_more_mixed_type9  s    "z%TestConcatenator.test_more_mixed_typec                 C   sB   t ddd }t|jdk t ddtd }t|jdk d S )Nr   rP   y              Y@)d   )r   r   r   r;   r   r   rC   rC   rD   test_complex_step=  s    z"TestConcatenator.test_complex_stepc                 C   s   t jdd}t jdd}td||f }t|jdk t|d d d df | t|d d dd f | t||f }t|jdk t|d dd d f | t|dd d d f | d S )Nr'   1)r'   rF   )rF   r'   )r;   randomrandr   r   r   r   )rA   rv   r|   rz   rC   rC   rD   test_2dF  s    zTestConcatenator.test_2dc                 C   sb   t tdtddf g d t tg dtdf g d t ttdg df g d d S )Nr   r   r   r   r   r   r%   )r   r   r   r%   rY   )r   r   r;   r@   rW   rC   rC   rD   r_   R  s     zTestConcatenator.test_0dN)	rl   rm   rn   r   r   r   r   r   r_   rC   rC   rC   rD   r   .  s   	r   c                   @   s   e Zd Zdd ZdS )TestNdenumeratec                 C   s0   t ddgddgg}ttt|g d d S )Nr   r   r%   r!   )))r   r   r   ))r   r   r   )r   r%   ))r   r   r!   )r;   r@   r   listr   rA   rf   rC   rC   rD   rE   Y  s    zTestNdenumerate.test_basicN)rl   rm   rn   rE   rC   rC   rC   rD   r   X  s   r   c                   @   s   e Zd Zdd Zdd ZdS )TestIndexExpressionc                 C   sJ   t d}t|d d |td d   t|d d |td d   d S )Nr   r    )r;   aranger   r   r   r   rC   rC   rD   test_regression_1`  s    
z%TestIndexExpression.test_regression_1c                 C   s   t jddd}t|d d d dddgf |td d d dddgf   t|d d d dddgf |td d d dddgf   d S )Nr!   r'   r&   r%   r   r   )r;   r   r   r   r   r   r   rC   rC   rD   test_simple_1f  s    :z!TestIndexExpression.test_simple_1N)rl   rm   rn   r   r   rC   rC   rC   rD   r   _  s   r   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestIx_c                 C   sb   t td\}t|jt j t g \}t|jt j t t jg t jd\}t|jt j d S )Nr   rG   )r;   r   ranger   rH   rQ   r@   r   r   rC   rC   rD   r   n  s    zTestIx_.test_regression_1c                    s   d}t tjfD ]| tj fdd|D  }tt||D ]P\\}}t|j | tt	fddt|jD  tt
|jtj q8qd S )N)r!   r'   r%   r   c                    s   g | ]} |qS rC   rC   )re   sz)funcrC   rD   
<listcomp>~  rh   z0TestIx_.test_shape_and_dtype.<locals>.<listcomp>c                 3   s"   | ]\}}| kr|d kV  qdS )r   NrC   )re   jsh)krC   rD   rg     rh   z/TestIx_.test_shape_and_dtype.<locals>.<genexpr>)r   r;   r   r   	enumerater~   r   r   r   rj   Z
issubdtyperH   integer)rA   sizesZarraysrf   r   rC   )r   r   rD   test_shape_and_dtypez  s     zTestIx_.test_shape_and_dtypec                 C   s,   g d}t |\}tt |d | d S )N)TFTTr   )r;   Znonzeror   r   )rA   Zbool_aZint_arC   rC   rD   	test_bool  s    zTestIx_.test_boolc                 C   s"   g dg dg}t ttj| d S )NrY   r!   r'   r&   )r   r?   r;   r   )rA   Zidx2drC   rC   rD   test_1d_only  s    zTestIx_.test_1d_onlyc                 C   sR   d}t |}t||}t|d j|df t|d jd|f t|j|f d S )Nr'   r   r   )r;   r   r   r   r   )rA   Zlength_of_vectorr[   outrC   rC   rD   test_repeated_input  s    

zTestIx_.test_repeated_inputN)rl   rm   rn   r   r   r   r   r   rC   rC   rC   rD   r   m  s
   
r   c                  C   s>   t jt g dgddt g dgf } t| g dg d S )NrY   r   r   )r   r   r%   r   r   r!   r'   r&   )r;   Zc_r@   r   )rf   rC   rC   rD   test_c_  s    *r   c                   @   sD   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S )TestFillDiagonalc                 C   s<   t dt}t|d t|t g dg dg dg d S )N)r%   r%   r'   r'   r   r   r   r'   r   r   r   r'   r;   rb   rK   r   r   r@   r   rC   rC   rD   rE     s    
zTestFillDiagonal.test_basicc                 C   sf   t dt}t|d t|t g dg dg dg dg dg dg dg dg dg dg
 d S )NrI   r'   r   r   r   r   r   r   r   r   rC   rC   rD   test_tall_matrix  s    
z!TestFillDiagonal.test_tall_matrixc                 C   sh   t dt}t|dd t|t g dg dg dg dg dg dg dg dg dg dg
 d S )NrI   r'   Tr   r   r   r   r   r   rC   rC   rD   test_tall_matrix_wrap  s    z&TestFillDiagonal.test_tall_matrix_wrapc                 C   s<   t dt}t|d t|t g dg dg dg d S )N)r%   rF   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   r   r   rC   rC   rD   test_wide_matrix  s    
z!TestFillDiagonal.test_wide_matrixc                 C   sD   t dt}t|d t g d}tt |dk||||f d S )N)r%   r%   r%   r%   r!   r   r   )r;   rb   rK   r   r@   r   where)rA   rf   irC   rC   rD   test_operate_4d_array  s    
z&TestFillDiagonal.test_operate_4d_arrayc                 C   sD   t dt}ttd t|d W d    n1 s60    Y  d S )Nr%   at least 2-dr'   r;   rb   rK   r   r?   r   r   rC   rC   rD   test_low_dim_handling  s    z&TestFillDiagonal.test_low_dim_handlingc                 C   sD   t dt}ttd t|d W d    n1 s60    Y  d S )N)r%   r%   r(   r%   equal lengthr   r   r   rC   rC   rD   test_hetero_shape_handling  s    z+TestFillDiagonal.test_hetero_shape_handlingN)
rl   rm   rn   rE   r   r   r   r   r   r   rC   rC   rC   rD   r     s   		r   c               	   C   s   t d} tg dg dg dg dg}d|| < t|tg dg dg d	g d
g t dd}tdt}d||< t|tddgddggddgddggg d S )Nr!   )r   r   r%   r!   )r'   r&   r(   r9   )r:   rF   ru   r8   )r0            r   )r   r   r%   r!   )r'   r   r(   r9   )r:   rF   r   r8   )r0   r   r   r   r   r%   )r   r   r   r   r   )r   r;   r@   r   rb   rK   )Zdirf   Zd3rC   rC   rD   test_diag_indices  s4    

r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestDiagIndicesFromc                 C   s<   t jd}t|\}}t|t d t|t d d S )Nr6   r!   )r;   r   r   r   r   )rA   r[   rr|   rC   rC   rD   test_diag_indices_from  s    z*TestDiagIndicesFrom.test_diag_indices_fromc                 C   s@   t d}ttd t| W d    n1 s20    Y  d S )Nr(   r   )r;   r{   r   r?   r   r^   rC   rC   rD   test_error_small_input  s    
z*TestDiagIndicesFrom.test_error_small_inputc                 C   sB   t dt}ttd t| W d    n1 s40    Y  d S )N)r%   r%   r   r%   r   )r;   rb   rK   r   r?   r   r^   rC   rC   rD   test_error_shape_mismatch  s    z-TestDiagIndicesFrom.test_error_shape_mismatchN)rl   rm   rn   r   r   r   rC   rC   rC   rD   r     s   r   c                  C   s   t tddd} dd ttdD }t| | t td} t| | t td} t| t td t t } t| dg t td} t| dg t td	g } t| g  d S )
Nr   r   r%   c                 S   s   g | ]\}}|qS rC   rC   )re   ZixerC   rC   rD   r     rh   z test_ndindex.<locals>.<listcomp>rY   )r%   rC   r   )r   r   r   r;   rb   r   r   )r[   r   rC   rC   rD   test_ndindex  s    


r   )"ro   numpyr;   Znumpy.testingr   r   r   r   r   r   r   Znumpy.lib.index_tricksr	   r
   r   r   r   r   r   r   r   r   r   r   rr   r   r   r   r   r   r   r   r   r   rC   rC   rC   rD   <module>   s   $4 .s**G