a
    Lf1                    @   s6  d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZd dlZd dl	m
Z
 d dlmZ d dlmZ d dl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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+m,Z,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ d dlAmB  mCZD d dlEmFZF d d	lGmHZH d
d ZIdd ZJG dd dZKG dd dZLG dd dZMG dd dZNejOPdg ddd ZQG dd dZRG dd dZSG dd dZTG d d! d!ZUG d"d# d#ZVG d$d% d%ZWG d&d' d'ZXG d(d) d)ZYG d*d+ d+ZZG d,d- d-Z[G d.d/ d/Z\G d0d1 d1Z]G d2d3 d3Z^G d4d5 d5Z_G d6d7 d7Z`G d8d9 d9Zadsd;d<Zbdtd>d?ZcG d@dA dAZdG dBdC dCZeG dDdE dEZfG dFdG dGZgejOPddHejhdI  ejhdJ  ejOPdKg dLG dMdN dNZiG dOdP dPZjG dQdR dRZkG dSdT dTZlG dUdV dVZmG dWdX dXZnG dYdZ dZZoG d[d\ d\ZpG d]d^ d^ZqG d_d` d`ZrG dadb dbZsG dcdd ddZtG dedf dfZuG dgdh dhZvg diZwdjgZxG dkdl dlZyG dmdn dnZzG dodp dpZ{G dqdr drZ|dS )u    NFraction)arrays)partial)maangleaveragebartlettblackmancorrcoefcovdeletediffdigitizeextractflipudgradienthamminghanningi0insertinterpkaisermeshgrid	piecewiseplacerot90selectsetxor1dsinc	trapezoid
trim_zerosunwrapunique	vectorize)	AxisError)assert_assert_equalassert_array_equalassert_almost_equalassert_array_almost_equalassert_raisesassert_allcloseIS_PYPYassert_warnsassert_raises_regexsuppress_warningsHAS_REFCOUNTIS_WASM)rand)normalize_axis_tuplec                 C   s   t | }t j||}|S N)nparangeaddouter)ndata r<   [/var/www/ai-form-bot/venv/lib/python3.9/site-packages/numpy/lib/tests/test_function_base.pyget_mat   s    
r>   c                 C   s(   t t | |jt j}| |_||_|S )za
    Like real + 1j * imag, but behaves as expected when imag contains non-finite
    values
    )r6   zeros	broadcastshape
complex128realimag)rC   rD   retr<   r<   r=   _make_complex%   s    rF   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )	TestRot90c                 C   s  t tttd t tttddd t tttddd t tttddd t tttddd g dg d	g}d
dgddgddgg}g dg dg}ddgddgdd
gg}g dg d	g}tdddD ]}tt||d| qtdddD ]}tt||d| qtdddD ]}tt||d| qtdddD ]}tt||d| q@ttt|dddd| tt|dddt|ddd d S )N      rJ   rJ   r      rJ   axesrJ   rJ   r   rJ   rL   rL   )rL      rH      rJ   rU   rL   r   rT   rU   rH   rT   rJ   rL   r      )krR   r   rL   rL   r   rZ   rN   )r+   
ValueErrorr   r6   onesranger'   )selfab1b2Zb3Zb4rZ   r<   r<   r=   
test_basic1   s@    zTestRot90.test_basicc                 C   sR   t d}tt|jd tt|ddt|dd tt|ddt|dd d S )N)2   (   rT   )rh   rg   rT   rP   rM   r   r[   rL   rJ   rR   r[   )r6   r`   r'   r   rA   rb   rc   r<   r<   r=   	test_axesQ   s    
zTestRot90.test_axesc                 C   s   t dd}ddgddggddgd	d
ggg}ddgddggd
dgd	dggg}d	dgddggd
dgddggg}d	d
gddggddgddggg}tt|dd| tt|dd| tt|dd| tdd
D ]&}tt||ddt||d dd qd S )N   rI   rJ   rT         r   rL   rH   rU   r\   rM   r]   rj   )rJ   r   r^   )r6   r7   reshaper'   r   ra   )rb   rc   Z
a_rot90_01Z
a_rot90_12Z
a_rot90_20Z
a_rot90_10rZ   r<   r<   r=   test_rotation_axesW   sH    zTestRot90.test_rotation_axesN)__name__
__module____qualname__rf   rm   rr   r<   r<   r<   r=   rG   0   s    rG   c                   @   sT   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S )TestFlipc                 C   sd   t ttjtddd t ttjtddd t ttjtddd t ttjtddd d S )NrH   rL   axisrH   rH   rJ   rX   r   rT   )r+   r%   r6   flipr`   rb   r<   r<   r=   rm   v   s    zTestFlip.test_axesc                 C   sf   t d}|d d d d df }tt|d| g dg dg}g dg dg}tt|d| d S )NrH   r[   rL   rK   rS   rW   rV   r>   r'   r6   r{   rb   rc   br<   r<   r=   test_basic_lr|   s    zTestFlip.test_basic_lrc                 C   sf   t d}|d d dd d f }tt|d| g dg dg}g dg dg}tt|d| d S )NrH   r[   r   rK   rS   r}   r~   r<   r<   r=   test_basic_ud   s    zTestFlip.test_basic_udc                 C   sb   t ddgddggddgddggg}t ddgddggddgddggg}tt |d| d S 	Nr   rL   rJ   rT   rH   rU   ro   rp   r6   arrayr'   r{   r~   r<   r<   r=   test_3d_swap_axis0   s    

zTestFlip.test_3d_swap_axis0c                 C   sb   t ddgddggddgddggg}t ddgddggddgddggg}tt |d| d S r   r   r~   r<   r<   r=   test_3d_swap_axis1   s    

zTestFlip.test_3d_swap_axis1c                 C   sb   t ddgddggddgddggg}t ddgddggddgddggg}tt |d| d S r   r   r~   r<   r<   r=   test_3d_swap_axis2   s    

zTestFlip.test_3d_swap_axis2c              	   C   sR   t ddddd}t|jD ],}tt ||t |d||d q d S )Nx   rJ   rT   rH   rU   r   )	r6   r7   rq   ra   ndimr'   r{   r   swapaxes)rb   rc   ir<   r<   r=   test_4d   s
    zTestFlip.test_4dc                 C   s@   t g dg dg}t g dg dg}tt || d S )NrL   rJ   rT   rH   rU   ro   )ro   rU   rH   rT   rJ   rL   r   r~   r<   r<   r=   test_default_axis   s    

zTestFlip.test_default_axisc                 C   s   t ddgddggddgddggg}tt j|d	d
| t ddgddggddgddggg}tt j|dd
| t ddgddggddgddggg}tt j|dd
| d S )Nr   rL   rJ   rT   rH   rU   ro   rp   r<   rw   rP   rj   r   rb   rc   r   cr<   r<   r=   test_multiple_axes   s0    


zTestFlip.test_multiple_axesN)rs   rt   ru   rm   r   r   r   r   r   r   r   r   r<   r<   r<   r=   rv   t   s   

rv   c                   @   s   e Zd Zdd Zdd ZdS )TestAnyc                 C   sH   g d}g d}g d}t t| t t| t t|  d S )Nr   r   rL   r   r   r   r   r   )rL   r   rL   r   )r&   r6   anyrb   y1y2y3r<   r<   r=   rf      s    zTestAny.test_basicc                 C   sX   g dg dg dg}t t| ttj|ddg d ttj|ddg d d S )Nr   r   r   r   rL   r   rL   rL   r   r   rw   rL   r   rL   rL   )r&   r6   r   r(   rb   r   r<   r<   r=   test_nd   s    zTestAny.test_ndNrs   rt   ru   rf   r   r<   r<   r<   r=   r      s   r   c                   @   s   e Zd Zdd Zdd ZdS )TestAllc                 C   s`   g d}g d}g d}t t|  t t| t t|  t tt|  d S )N)r   rL   rL   r   r   rL   rL   rL   rL   )r&   r6   allr   r   r<   r<   r=   rf      s    zTestAll.test_basicc                 C   sZ   g dg dg dg}t t|  ttj|ddg d ttj|ddg d d S )Nr   r   rL   r   rL   rL   rL   r   rw   rL   )r&   r6   r   r(   r   r<   r<   r=   r      s    zTestAll.test_ndNr   r<   r<   r<   r=   r      s   	r   dtype)i8ZU10objectzdatetime64[ms]c                 C   s>   t jd| d}t |jt jks$J t |jt jks:J d S )NrT   r   )r6   r`   r   r   boolr   )r   arrr<   r<   r=   test_any_and_all_result_dtype   s    r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestCopyc                 C   sR   t ddgddgg}t |}t|| d|d< t|d d t|d d d S )NrL   rJ   rT   rH   
   )r   r   )r6   r   copyr(   r'   )rb   rc   a_copyr<   r<   r=   rf     s    

zTestCopy.test_basicc                 C   s   t ddgddgg}t|jj t|jj  t jddgddggdd}t|jj  t|jj t |}t|jj t|jj  t |}t|jj  t|jj d S )NrL   rJ   rT   rH   Forder)r6   r   r&   flagsc_contiguousf_contiguousr   )rb   rc   Za_fortr   Za_fort_copyr<   r<   r=   
test_order  s    

zTestCopy.test_orderc                 C   sV   t d}tt tj|dd  tt tj|dd tt t|  d S )NrU   F)ZsubokT)r   r`   r&   ZisMaskedArrayr6   r   )rb   Zmxr<   r<   r=   
test_subok   s    
zTestCopy.test_subokN)rs   rt   ru   rf   r   r   r<   r<   r<   r=   r     s   r   c                   @   s   e Zd Zdd Zejdg dddgg ddgd	gfg d
g dgdg dgddgg dgg dgfg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 )"TestAveragec                 C   s   t g d}tt|dddk t g d}tt|dddk g d}tt|dddk t d}d|d	< d
|d< t|dt|d t|dt|d tdd}t|dt|d t|dt|d d S )Nr   r   rw          @      ?r         @)        r   r   r   ry   r\   rJ   r]   rL   rU   )r6   r   r&   r   r`   r)   meanr3   )rb   r   r   r   Zy4Zy5r<   r<   r=   rf   *  s    

zTestAverage.test_basicz<x, axis, expected_avg, weights, expected_wavg, expected_wsumr   Nr   )rT   rH   rL         ?       @)rL   rJ   rU   )rL   ro      r   )r         @r   rL   rT   )r         @      #@rH   rH   rH   c           
      C   s   t j||dd}|jt |ks$J t|| t j|||dd}|jt |ksTJ t|| t j|||ddd\}}	|jt |ksJ t|| |	jt |ksJ t|	| d S )NTrx   keepdims)rx   weightsr   )rx   r   returnedr   )r6   r   rA   r(   )
rb   xrx   Zexpected_avgr   Zexpected_wavgZexpected_wsumavgZwavgZwsumr<   r<   r=   test_basic_keepdims<  s    



zTestAverage.test_basic_keepdimsc                 C   s
  t d}t d}t||d}t dd  d t d  }t|| t g dg dg}ddg}t||dd	}t g d
}t|| g d}t||dd	}t ddg}t|| tjtdd t||d W d    n1 s0    Y  g dg dg}t ddg}t	t||dd	| t
t||dd tdt j}	tdt j}
tt j|	|
djt |	|
k t g ddd}t g ddd}t j||ddd}t g d}t	|| t j||ddd}t dgdgdgg}t	|| d S )Nr   r   rJ   r   r   r   rL   r   r   rx   )r   r   r   r   r         @z:Axis must be specified when shapes of a and weights differmatch)r   r   rJ   r   rU   rJ   rT   rH   rT   F)r   rx   r   )r   r   r   Tr   r   )r6   r7   r   sumr)   r   pytestraises	TypeErrorr(   r'   r3   astypefloat32float64r&   r   result_typerq   )rb   ywactualdesiredr   w0w1w2r   Zw3r   r<   r<   r=   test_weightsS  sD    

$


* 
zTestAverage.test_weightsc                 C   s  t dddd}t g dddd}|d d d d df }t|d|d}t g d}t|| |d	d d d d f }t|d
|d}t ddg}t|| |d d dd d f }t|d|d}t ddg}t|| tjtdd t|d|d W d    n1 s0    Y  tjtdd t|d|d W d    n1 sR0    Y  t|d|d}t|d|j	d}t|| t|d|d}t
|jdk d S )N   rJ   rT   )r   r   r         ?r   r   r   r   r   r   r   r   r   r\   )rx   r         @r         "@rL   rj   g      @g      @rP         @g      @zHShape of weights must be consistent with shape of a along specified axisr   rK   r]   )r6   r7   rq   r   r   r)   r   r   r_   Tr&   r   )rb   r   r   Zsubw0r   r   Zsubw1Zsubw2r<   r<   r=   $test_weight_and_input_dims_different  s>    


..
z0TestAverage.test_weight_and_input_dims_differentc                 C   s  t g dg dg}t|dd\}}t|d t|ddd\}}t|t g d t|ddd\}}t|t d	d	g dd
g}t||ddd\}}t|t g d g d}t||ddd\}}t|t ddg g dg dg}t||ddd\}}t|t ddg d S )Nr   r   T)r   r   r   )r   r   r   rL   r   rJ   )r   rx   r   )r   r   r   r   r   )r6   r   r   r'   r(   )rb   r   r   Zsclr   r   r   r<   r<   r=   test_returned  s     
zTestAverage.test_returnedc                 C   sz   G dd dt j}t ddgddgg|}t ddgddgg|}ttt || ttt j||d| d S )Nc                   @   s   e Zd ZdS )z-TestAverage.test_subclasses.<locals>.subclassNrs   rt   ru   r<   r<   r<   r=   subclass  s   r   rL   rJ   rT   rH   r   )r6   ndarrayr   viewr'   typer   )rb   r   rc   r   r<   r<   r=   test_subclasses  s
    zTestAverage.test_subclassesc                 C   sl   g d}|D ]Z\}}}t jddgddgg|d}t jddgddgg|d}tt j||djt | qd S )N))i4r   f8)r   f4r   )r   r   r   )r   r   r   )r   r   r   rL   rJ   rT   rH   r   r   )r6   r   r'   r   r   )rb   Ztypsatwtrtrc   r   r<   r<   r=   test_upcasting  s
    zTestAverage.test_upcastingc                 C   sX   t dd tdD }t dd tdD }||  }t|dt||d d S )Nc                 S   s   g | ]}t |qS r<   decimalDecimal).0r   r<   r<   r=   
<listcomp>      z1TestAverage.test_object_dtype.<locals>.<listcomp>r   c                 S   s   g | ]}t d qS rL   r   )r   _r<   r<   r=   r     r  r   r   )r6   r   ra   r   r)   r   r   )rb   rc   r   r<   r<   r=   test_object_dtype  s    zTestAverage.test_object_dtypec                 C   s4   t tddtddg}tt |tdd d S )NrL   rU   rT   rJ   )r6   r   r   r'   r   rl   r<   r<   r=    test_average_class_without_dtype  s    z,TestAverage.test_average_class_without_dtype)rs   rt   ru   rf   r   markparametrizer   r   r   r   r   r   r  r  r<   r<   r<   r=   r   (  s"   
0*	r   c                   @   s   e Zd Zeg deg deg dgZeg deg deg dgZddd	Zd
d Zdd Z	dd Z
dd Zdd Zdd ZdS )
TestSelectr   r   rp   rn   	   )FFFFTFFFTr   c                    s<   g }t t|D ]& | fddt||D p2|g7 }q|S )Nc                    s    g | ]\}}|  r|  qS r<   r<   )r   VCmr<   r=   r     r  z&TestSelect._select.<locals>.<listcomp>)ra   lenzip)rb   Zcondvaluesdefaultoutputr<   r  r=   _select  s    $zTestSelect._selectc                 C   sL   | j }| j}tt||dd| j||dd tt|d tt|d d S )N   r  rT   )choices
conditionsr(   r   r  r'   r  rb   r  r  r<   r<   r=   rf     s    zTestSelect.test_basicc                 C   sd   t dt g dg}dt dddg}tt||t d ttdgdgdgd	jd
 d S )NTr  rL   r   rH   rT   rH   rT   r   r  r  )	r6   r   r7   rq   r(   r   r`   r'   rA   rb   r  r  r<   r<   r=   test_broadcasting  s    zTestSelect.test_broadcastingc                 C   s   t t| j| jdjtj dd | jD }t t| j|jtj tdddtj	ddg}t
|}t t|g|gd	d	d	tj	d	d	g d S )
N              ?c                 S   s   g | ]}| tjqS r<   )r   r6   int8)r   choicer<   r<   r=   r     r  z0TestSelect.test_return_dtype.<locals>.<listcomp>rL   rJ   rT   rU   rp   r   )r'   r   r  r  r   r6   rB   r   r   nanisnan)rb   r  dr  r<   r<   r=   test_return_dtype  s    
zTestSelect.test_return_dtypec                 C   s"   t ttg g d t ttg g  d S )N              @)r+   r_   r   r|   r<   r<   r=   test_deprecated_empty  s    z TestSelect.test_deprecated_emptyc                 C   sj   | j }| jd d  }|d tj|d< ttt|| |d tj|d< ttt|| ttt|| d S Nr   )	r  r  r   r6   int_r+   r   r   uint8r  r<   r<   r=   test_non_bool_deprecation  s    z$TestSelect.test_non_bool_deprecationc                 C   s2   t dggd }t dggd }t|| d S )NFd   rL   )r6   r   r   r  r<   r<   r=   test_many_arguments  s    zTestSelect.test_many_argumentsN)r   )rs   rt   ru   r6   r   r  r  r  rf   r  r%  r'  r+  r-  r<   r<   r<   r=   r    s   
		r  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d Z	e
jdddgdd ZdS )
TestInsertc                 C   sv  g d}t t|ddg d t t|ddg d t t|g dg dg d t t|dg dg d t t|g d	d
g d t t|tdd dd
g d t t|g dg dg d tjddgtjd}t t|d|d g d t t|g g | tjddR}tddt	 t t|tdgd d
g d t
|d jt	u  W d    n1 sh0    Y  d S )Nr   r   rL   )rL   rL   rJ   rT   rT   )rL   rJ   rT   rL   r   )rL   rL   rJ   rT   rJ   rT   )rL   r[   rT   r
  )rL   r
  rJ   r
  rT   r
  r[   )r
  rL   r
  rJ   r
  rT   r[   rL   rT   r	  )rL   rn   rJ   rp   rT   r
  r   r   r   r   Trecordalways rH   )rL   r
  r
  r
  r
  rJ   rT   )r'   r   slicer6   r   r   warningscatch_warningsfilterwarningsFutureWarningr&   category)rb   rc   r   r   r<   r<   r=   rf   #  s"    zTestInsert.test_basicc              
   C   sz  g dg}g dg dg}t t|ddgg d t t|dg ddd| t t|dddd| t t|ddddg dg tddgddgd	d	gg}tdd
d	d	d	}tj|d d ddf tdd
d	d	d	j|d d ddf fdd}t t|dgdgdgd	ggdd| t t|dgg ddd| t t|dg ddd| t t|ddgdgd	ggdd| td
dd}t t|d d d df d|d d df dd| t t|d dd d f d|dd d f dd| tdd}t t|d|d d d d d	f ddt|d|d d d d d	f dd t t|d|d d dd d f ddt|d|d d dd d f dd t	t
t|d|d d dd d f d	d t	t
t|d|d d dd d f dd tdd}t t|d|d d d d d	f ddt|d|d d d d d	f dd t t|d|d d dd d f ddt|d|d d dd d f dd d S )Nr   rI   r   rL   r   rw   rJ   )rL   rL   rJ   rL   rT   rH   r      r   r[   rR   )r'   r   r6   r   r7   repeatrq   Zconcatenater   r+   r%   )rb   rc   rr   r   r<   r<   r=   test_multidim7  sN    
,$"22" " &&" " zTestInsert.test_multidimc                 C   s   t d}tt  t|g ddd W d    n1 s:0    Y  tt  t|g ddd W d    n1 st0    Y  d S )NrL   rJ   r   rw   nonsense)r6   r   r   r   r%   r   r   rl   r<   r<   r=   test_0da  s
    
.zTestInsert.test_0dc              	   C   s   G dd dt j}t d|}ttt |ddg| ttt |g g | ttt |ddgddg| ttt |tddddg| ttt |tdddg | t d|}ttt |ddg| d S )	Nc                   @   s   e Zd ZdS )z*TestInsert.test_subclass.<locals>.SubClassNr   r<   r<   r<   r=   SubClassi  s   rB  r   r   rL   rJ   rR   r[   )	r6   r   r7   r   r&   
isinstancer   r5  r   rb   rB  rc   r<   r<   r=   test_subclassh  s     " zTestInsert.test_subclassc                 C   s<   t g d}t g d|g d t|t g d d S )Nr   rK   rS   )r6   r   r   r'   rb   r   r<   r<   r=   test_index_array_copiedu  s    z"TestInsert.test_index_array_copiedc                 C   s   t jg dddgd}d}t |d|}t|d t j||jd dgd }t |ddg|}t|ddg t j||jd d S )	N))rL   rc   )rJ   r   )rT   r   )foor   )barZS1r   )rH   r$  r   rJ   rT   )r6   r   r   r(   r   )rb   rc   valr   r<   r<   r=   test_structured_arrayz  s    

z TestInsert.test_structured_arrayc                 C   s   t t0 tg dtddgddg W d    n1 s@0    Y  t t, tg dtjg tdg  W d    n1 s0    Y  d S )NrK   r   r   r      r   )r   r   
IndexErrorr6   r   r   floatr|   r<   r<   r=   test_index_floats  s    >zTestInsert.test_index_floatsidxrH   r<  c                 C   sJ   t jtdd( tg d|gddg W d    n1 s<0    Y  d S )Nzout of boundsr   rK   rT   rH   )r   r   rM  r6   r   )rb   rP  r<   r<   r=   test_index_out_of_bounds  s    z#TestInsert.test_index_out_of_boundsN)rs   rt   ru   rf   r?  rA  rE  rG  rK  rO  r   r  r  rQ  r<   r<   r<   r=   r.  !  s   *
r.  c                   @   s   e Zd Zdd ZdS )TestAmaxc                 C   sb   g d}t t|d g dg dg dg}t tj|ddg d t tj|d	dg d
 d S )NrT   rH   rU   r   rX   r         $@rT   r   r   rH   rU  r   rn   r   r   r   rw   )r   rU  r   rL   )r   rU  r   )r'   r6   Zamaxr~   r<   r<   r=   rf     s    zTestAmax.test_basicNrs   rt   ru   rf   r<   r<   r<   r=   rR    s   rR  c                   @   s   e Zd Zdd ZdS )TestAminc                 C   sb   g d}t t|d g dg dg dg}t tj|ddg d t tj|d	dg d
 d S )NrS  g      rV  rW  rX  r   rw   )r   r   r   rL   )r   r   r   )r'   r6   aminr~   r<   r<   r=   rf     s    zTestAmin.test_basicNrY  r<   r<   r<   r=   rZ    s   rZ  c                   @   s   e Zd Zdd ZdS )TestPtpc                 C   s   t g d}tt j|ddd t g dg dg dg}tt j|ddg d tt j|d	dg d
 tt j|dddg dg tt j|ddddgg d S )NrS  r   rw         .@rV  rW  rX  )r   r   r   r[   )r   r   r   Tr   r\   r   )r6   r   r'   Zptpr~   r<   r<   r=   rf     s    
zTestPtp.test_basicNrY  r<   r<   r<   r=   r\    s   r\  c                   @   s   e Zd Zdd ZdS )
TestCumsumc              
   C   s   g d}g dg dg dg}t jt jt jt jt jt jt jt jt j	t j
f
D ]}t ||}t ||}t g d|}tt j|dd| t g dg dg d	g|}tt j|dd| t g d
g dg dg|}tt j|dd| qJd S )NrL   rJ   r   r   ro   rU   rH   rL   rJ   rT   rH   rU   ro   rp   r
  r   rT   rH   rU   )rL   rT   rY   r;     #   '   r   rw   )ro   rn   r   rY   )   r         )rL   rT   ro   r   )rU   r   rh     )r   rY         rL   )r6   r   r*  int16uint16int32uint32r   r   	complex64rB   r   r(   cumsum)rb   baba2ctyperc   a2tgtr<   r<   r=   rf     s$    zTestCumsum.test_basicNrY  r<   r<   r<   r=   r^    s   r^  c                   @   s   e Zd Zdd ZdS )TestProdc                 C   s   g d}g dg dg dg}t jt jt jt jt jt jt jt jfD ]}t 	||}t 	||}|dv rt
tt j| t
tt j|d qBt|jddd	 t|jddt 	g d
| t|jddt 	g d| qBd S )Nr_  r`  ra  rb  1r   rL   r   rw    g  rg   $   T      r[   )r;  b  X  )r6   rl  rm  rn  ro  r   r   rp  rB   r   r+   ArithmeticErrorprodr'   r(   rb   rr  rs  rt  rc   ru  r<   r<   r=   rf     s"    zTestProd.test_basicNrY  r<   r<   r<   r=   rw    s   rw  c                   @   s   e Zd Zdd ZdS )TestCumprodc              	   C   s  g d}g dg dg dg}t jt jt jt jt jt jt jt jfD ]}t 	||}t 	||}|dv rt
tt j| t
tt j|d t
tt j| qBtt j|ddt 	g d	| tt j|d
dt 	g dg dg dg| tt j|ddt 	g dg dg dg| qBd S )Nr_  r`  ra  rb  rx  rL   r[   rw   )rL   rJ   rL     i(  i  rz  r   )rU   r      r|  r{  )rL   rJ   ro   r;  )rU   rc     r  )r   rc  r   r  )r6   rl  rm  rn  ro  r   r   rp  rB   r   r+   r  Zcumprodr(   r  r<   r<   r=   rf     s@    


zTestCumprod.test_basicNrY  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S )TestDiffc                 C   s   g d}t g d}t g d}t ddg}tt|| tt|dd| tt|dd| g d	}t g d
}tt|| g d}t g d}t ddg}tt|| tt|dd| d S )N)rL   rH   ro   rp   r   )rT   rJ   rL   rU   )r[   r[   rH   r   rU   rJ   r:   rT   )皙?皙@r   gɿ皙)r  皙?g	皙?)TTFFr  T)r6   r   r(   r   r)   )rb   r   outout2out3r<   r<   r=   rf     s    zTestDiff.test_basicc                 C   s   t d}d|d d dd dd d f< t d}d|d d dd dd d f< tt|t d tt|ddt d tt|ddt d	 tt|dd| tt|d
d| ttt|dd ttt|dd t dt j}tt	t| d S )N)r   rL  rc  rL   rJ   )r      rc  r[   )r   rL     rw   r   )r
  rL  rc  rR   rT   r<  gq?)
r6   r?   r`   r(   r   r+   r%   r   r   r_   )rb   r   expr<   r<   r=   	test_axis  s    

zTestDiff.test_axisc                 C   s*  dt ddd }|d d d d dd f |d d d d d df  }|d d d d dd f |d d d d d df  }|dd d d d d f |d dd d d d f  }|dd d d d d f |d dd d d d f  }tt|| tt|dd| tt|dd	| tt|ddd
| d S )NrL  r   rc  rL   r[   rJ   r  r   rw   )r:   rx   )r3   r(   r   )rb   r   Zout1r  r  Zout4r<   r<   r=   r   "  s    4444zTestDiff.test_ndc                    s   t td ttt dd  fddtddD }ddgdgg g g}tt dd u  tt||dd	D ]R\}\}}tt|t	j
u  t|| t|jt	j tt|tdt |  qld S )
NrT   r[   r  c                    s   g | ]}t  |d qS )r  )r   )r   r:   r   r<   r=   r   0  r  z#TestDiff.test_n.<locals>.<listcomp>rL   rU   r   start)listra   r+   r_   r   r&   	enumerater  r   r6   r   r(   r'   r   r)  r  max)rb   r  expectedr:   r  r<   r  r=   test_n-  s    
zTestDiff.test_nc                 C   s   t jddt jd}t jddgddt jdgddg}|t jg ddgd  t|ddD ],\}}t||d	}t|| t|j	|j	 qZd S )
Nz
1066-10-13z
1066-10-16r   rL   timedelta64[D]r   rT   r  r  )
r6   r7   Z
datetime64r   extendr  r   r(   r'   r   )rb   r   r  r:   r  r  r<   r<   r=   
test_times9  s    
zTestDiff.test_timesc                 C   s   t jddgddgddgddgd	d
ggddgddgddgddgddggd}t|}t|jdgdgdgdgdgg t|jdgdgdgdgdgg tt|t|u  t|dd}t|jg g g g g g t|jg g g g g g tt|t|u  d S )NrL   rJ   rT   rH   rU   ro   rp   rn   r
  r   FTmaskr  )r   r   r   r(   r;   r  r&   r   )rb   r   r  r  r<   r<   r=   rE  E  s    $ zTestDiff.test_subclassc                 C   sL  t dd }tt|ddt d tt|dgdt d tt t j|dd| tt|ddgdt d t ddd}t j|ddd	}ddgddgg}t|| t j|ddgdggd	}t|| t j|ddd	}ddgddgg}t|| t j|dddggd	}t|| ttt j|t 	d
d tt
t|ddd d S )NrU   rL   r   )prependr[   ro   rH   rJ   )rx   r  rT   rT   rT   )r  rx   )r6   r7   r(   r   r`   rq  rq   r+   r_   r?   r%   rb   r   resultr  r<   r<   r=   test_prependT  s$    



zTestDiff.test_prependc                 C   s:  t d}t|dd}g d}t|| t|dgd}t|| t|ddgd}|dg }t|| t ddd}t j|ddd}dd	gdd
gg}t|| t j|ddgdggd}t|| t j|ddd}ddgdd
gg}t|| t j|dddggd}t|| ttt j|t dd ttt|ddd d S )NrU   r   )append)rL   rL   rL   rL   r<  rJ   rH   rL   )rx   r  r[   rX   rR   r  rT   )r  rx   )	r6   r7   r   r(   rq   r+   r_   r?   r%   r  r<   r<   r=   test_appendl  s,    








zTestDiff.test_appendN)rs   rt   ru   rf   r  r   r  r  rE  r  r  r<   r<   r<   r=   r    s   r  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d Z	dd Z
dd Zejdedgdggdd Zdd ZdS )
TestDeletec                 C   s,   t d| _t ddddd| _d S )NrU   rJ   rL   )r6   r7   rc   r=  rq   nd_ar|   r<   r<   r=   setup_method  s    zTestDelete.setup_methodc                 C   s   t | j|}t | j|dd}d| }tt|| j|f | j|d t|dd d df | jd|df }t|| jdd d df |d d S )NrL   rw   zDelete failed for obj: %r)err_msgr   )r   rc   r  r(   r   )rb   indicesa_delnd_a_delmsgxorr<   r<   r=   _check_inverse_of_slicing  s    $z$TestDelete._check_inverse_of_slicingc                 C   sH   g d}g d}|D ].}|D ]$}|D ]}t |||}| | q$qqd S )N)rR   r   rL   rJ   rH   rU   )rX   r[   rL   rT   )r5  r  )rb   ZlimsZstepsr  stopstepsr<   r<   r=   test_slices  s    zTestDelete.test_slicesc                 C   sX  |  tddgddgg tt t| jdg W d    n1 sJ0    Y  tt t| jdg W d    n1 s0    Y  |  g d |  g d tt t| jd W d    n1 s0    Y  tt t| jd	 W d    n1 s0    Y  tt" t| jd	gd
  W d    n1 sJ0    Y  d S )Nr   rL   rJ   r,  i)r   r[   rJ   rJ   )TFFTFTFrH   )	r  r6   r   r   r   rM  r   rc   r_   r|   r<   r<   r=   
test_fancy  s    ,,*,zTestDelete.test_fancyc                 C   s   |  d |  d d S )Nr   r<  )r  r|   r<   r<   r=   test_single  s    
zTestDelete.test_singlec                 C   s~   t d}tt t|g dd W d    n1 s80    Y  tt t|g dd W d    n1 sp0    Y  d S )NrL   r   rw   r@  )r6   r   r   r   r%   r   r   rl   r<   r<   r=   rA    s
    
,zTestDelete.test_0dc                 C   s   G dd dt j}| j|}ttt|d| ttt|g | ttt|ddg| ttt|tdd| ttt|tdd| d S )Nc                   @   s   e Zd ZdS )z*TestDelete.test_subclass.<locals>.SubClassNr   r<   r<   r<   r=   rB    s   rB  r   rL   rJ   rR   )r6   r   rc   r   r&   rC  r   r5  rD  r<   r<   r=   rE    s    zTestDelete.test_subclassc                 C   sR   t djdddd}t|tdd dd}t|jj|jj t|jj|jj d S )	Nr   rJ   rU   r   r   <   rL   rw   )	r6   r7   rq   r   r5  r'   r   r   r   )rb   rZ   r  r<   r<   r=   test_array_order_preserve  s    z$TestDelete.test_array_order_preservec                 C   s   t t* tg dtddg W d    n1 s:0    Y  t t* tg dtjg td W d    n1 s~0    Y  d S )NrK   r   r   r   )r   r   rM  r6   r   r   rN  r|   r<   r<   r=   rO    s    8zTestDelete.test_index_floatsindexerrL   c                 C   sX   t | jd}t | j|}t|| t | jddd}t | jtdgdd}t|| d S )NrL   rw   )r   rc   r'   r  r6   r   )rb   r  Z	a_del_intr  Znd_a_del_intr  r<   r<   r=   test_single_item_array  s    
z!TestDelete.test_single_item_arrayc                 C   s$  t tdtdg}t|td td}tjdgtd}tjdgtd}t ||dd}t|| t ||dd}t||d d d df  tt, t td	tjdgt	d W d    n1 s0    Y  tt, t td	tjdgd
d W d    n1 s0    Y  d S )NrL   F)rT   rL   r   Tr[   rw   r   rJ   zm8[ns])
r   r6   r`   r   r(   r   r   r   rM  r   )rb   resr   Z
false_maskZ	true_maskr<   r<   r=   test_single_item_array_non_int  s    

:z)TestDelete.test_single_item_array_non_intN)rs   rt   ru   r  r  r  r  r  rA  rE  r  rO  r   r  r  r6   r   r  r  r<   r<   r<   r=   r    s   		


	r  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d Z	dd Z
dd Zdd Zdd Zejdejejejejgdd Zejdejejejejgdd Zejdejejejejgdd Zejdejejejejgdd  Zd!d" Zd#S )$TestGradientc                 C   sf   ddgddgg}t |}t ddgddggt ddgddggg}tt|| tt|| d S )NrL   rT   rH   r   r   r   r   )r6   r   r(   r   rb   vr   dxr<   r<   r=   rf      s    
zTestGradient.test_basicc              	   C   s   t t d}g d}t ddd}tt dd tt dt d tt d| t|d t|t d t||| t||d t||dd ttd	t|t j	|gd d
dd d S )NrU   )r   r   r   r         &@   r         ?rJ   rL   rw   z.*scalars or 1dr[   )
r6   rq  r`   r7   rq   r   r   r/   r_   stack)rb   r  Z	dx_unevenf_2dr<   r<   r=   	test_args  s    
zTestGradient.test_argsc                 C   s   t ddd}t t d}ttt||t d ttt|dt d ttt|t dt d ttt|| ttt||dd ttt|||| ttt|ddd ttt|||dd ttt|dddd d S )Nr  rU   rJ   rL   r\   rw   )	r6   r7   rq   rq  r`   r+   r_   r   r   )rb   r  r   r<   r<   r=   test_badargs!  s    zTestGradient.test_badargsc                 C   sJ   t jg ddd}t jg ddd}tt|| t|jt dk d S )N)z
1910-08-16z
1910-08-11z
1910-08-10z
1910-08-12z
1910-10-12z
1910-12-12z
1912-12-12zdatetime64[D]r   )rT  rX   r      =   i  i  r  r6   r   r(   r   r&   r   rb   r   r  r<   r<   r=   test_datetime641  s    zTestGradient.test_datetime64c                 C   s   t jjddgddggddgddggd}t|d }tt|t| t|j|ju t jd}t jj	|d< t j|dd	 t
|jg d
 d S )NrL   rT   rH   Fr  r   rU   rJ   
edge_order)FFTFF)r6   r   r   r   r'   r   r&   Z_maskr7   maskedr(   r  )rb   r   r  x2r<   r<   r=   test_masked=  s    zTestGradient.test_maskedc                 C   s  t ddd}|d |d  }d|d  d|d   d|  }d|d  d|  d }t t j||dd	| d }tt |d
k dk t jd t t jd}d|d  d|d   d|  }d|d  d|  d }t t j||dd	| d }tt |d
k dk d S )Nr   rL   r   rJ   rT   rH   ro   rn   r  gQ?T)	r6   linspaceabsr   r&   r   randomseedsort)rb   r   r  r   Z
analyticalZ	num_errorr<   r<   r=   test_second_order_accurateL  s      z'TestGradient.test_second_order_accuratec                 C   s  t g d}t |d|dd }t g d}t d}t g dd}t g dd}t g d	d}t g d
d}d|fd|ffD ]\}}	t|dd|d}
t|||d|d}t|||d |d}t|
| t|| t|
d |	j t|
d |	 t|dd|d}
t||d|d}t	|
j
|j
k t||	j t|dd|d}
t||d|d}t	|
j
|j
k t||	 qd|fd|ffD ]\}}	t|||d|d}
t|||d |d}t|
| t|
d |	j t|
d |	 t||d|d}
t|
|	j t||d|d}
t|
|	 qt|||ddd}
t|||ddd}t|
d |d  t|
d |d  t|
d |j t|
d | t|||ddd}
t|||ddd}t|
d |d  t|
d |d  t|
d |j t|
d | d S )N)r   r   r   r   r   r   )ro   rL   r[   rL   )r   r   r   r   r   r   r   )r   r  r   r   r   r   )      @r  r   r   r         )r   r   333333?r         ?r   )r   r   r  r   r  g      пrJ   r   r\   )rx   r  r   r]   )r6   r   Ztilerq   r7   r   r(   r)   r   r&   rA   )rb   fZx_unevenZx_evenZfdx_even_ord1Zfdx_even_ord2Zfdx_uneven_ord1Zfdx_uneven_ord2r  Zexp_resres1res2res3r<   r<   r=   test_spacing`  sl    



zTestGradient.test_spacingc                 C   s<  ddgddgg}t |}t ddgddggt ddgddggg}tt|dd	|d  tt|dd	|d  tt|d
d	|d  tt|dd	|d |d g tt|d d	|d |d g tt|d d	t| tt|dddd	|d d |d d g ttt|dddd	 ttt|dd	 ttt|dd	 d S )NrL   rT   rH   r   r   r   r   r   rw   r[   r]   rJ   rX   )r6   r   r(   r   r)   r+   r   r%   r  r<   r<   r=   test_specific_axes  s"    
zTestGradient.test_specific_axesc                 C   sJ   t jg ddd}t jg ddd}tt|| t|jt dk d S )N)rT  rX   r   r   r  iA  ,  r  r   )rJ   rp   rp   r     w   ir  r  r<   r<   r=   test_timedelta64  s    zTestGradient.test_timedelta64c                 C   sD   t jt jt jfD ].}t jg d|d}tt|jt |j qd S )Nr   r   )	r6   float16r   r   r   r'   r   r   r   )rb   dtr   r<   r<   r=   test_inexact_dtypes  s    z TestGradient.test_inexact_dtypesc                 C   s   t tddd t tddd ttt tddd ttt tddd ttt tddd ttt tddd ttt tddd d S )NrJ   rL   r  rT   r   )r   r6   r7   r+   r_   r|   r<   r<   r=   test_values  s    zTestGradient.test_valuesf_dtypec                 C   s2   t jg d|d}t|}t|dgt|  d S )N)rU   rH   rT   rJ   rL   r   r[   r6   r   r   r(   r  )rb   r  r  gr<   r<   r=   test_f_decreasing_unsigned_int  s    z+TestGradient.test_f_decreasing_unsigned_intc                 C   sR   t |j}t ddg}t jd|g|d}t||}t||d d gd  d S )NrL   rT   r[   r   rJ   )r6   iinfor  r   r   r(   )rb   r  maxintr   r  dfdxr<   r<   r=   test_f_signed_int_big_jump  s
    
z'TestGradient.test_f_signed_int_big_jumpx_dtypec                 C   sB   t jg d|d}t g d}t||}t|dgt|  d S )Nr   r   r   rJ   rH   rR   r  )rb   r  r   r  r  r<   r<   r=   test_x_decreasing_unsigned  s    
z'TestGradient.test_x_decreasing_unsignedc                 C   sX   t |j}t |j}t jd|g|d}t |d dg}t||}t|ddg d S )Nr[   r   rJ   r   r   )r6   r  minr  r   r   r(   )rb   r  Zminintr  r   r  r  r<   r<   r=   test_x_signed_int_big_jump  s    
z'TestGradient.test_x_signed_int_big_jumpc                 C   s*   t ddgddgf}t|tu s&J d S )NrL   rJ   rT   )r6   r   r   tuplerb   r  r<   r<   r=   test_return_type  s    zTestGradient.test_return_typeN)rs   rt   ru   rf   r  r  r  r  r  r  r  r  r  r  r   r  r  r6   r*  rm  ro  Zuint64r  r   rl  rn  Zint64r  r  r  r  r<   r<   r<   r=   r    s8   @



r  c                   @   s   e Zd Zdd Zdd ZdS )	TestAnglec                 C   s   dt dd dt d d  dddddd	g}t|}t d
t ddt jd t jt j d t d
 t jt d
 g}t|dd}t |d t j }t||d t||d d S )N      ?      @rJ   r   r  rL   r[                      ?      y            @r   r   r   T)degr~  r   )r6   sqrtr   arctanpir   r*   )rb   r   r   ZyozZzor<   r<   r=   rf      s      zTestAngle.test_basicc                 C   s   t jddt dd d g}t jj|d< t jt ddt dg}t jj|d< t|}tt|t| t|j	|j	 t|| d S )Nr  rL   rJ         ?      ?r   r   r   )
r6   r   r   r  r  r  r   r'   r   r  )rb   r   r  r   r<   r<   r=   rE    s     zTestAngle.test_subclassN)rs   rt   ru   rf   rE  r<   r<   r<   r=   r    s   r  c                	   @   s   e Zd Zeg dZeeZee	Z
eeZdd Zdd Zdd Zdd	 Zd
d Zdd Zejdeg deg deg dgdd Zdd Zdd ZdS )TestTrimZeros)r   r   rL   r   rJ   rT   rH   r   c                    s   d} fdd|D S )N)rc   r   r   r$  c                 3   s   | ]}t  |V  qd S r5   )getattr)r   namer|   r<   r=   	<genexpr>!  r  z'TestTrimZeros.values.<locals>.<genexpr>r<   )rb   Z
attr_namesr<   r|   r=   r    s    zTestTrimZeros.valuesc                 C   s6   t jdd }|  D ]}t|}t|||  qd S )NrJ   r[   r6   s_r  r!   r(   rb   slcr   r  r<   r<   r=   rf   #  s    zTestTrimZeros.test_basicc                 C   s:   t jd d }|  D ]}t|dd}t|||  qd S )Nr[   r   Ztrimr  r  r<   r<   r=   test_leading_skip)  s    zTestTrimZeros.test_leading_skipc                 C   s:   t jdd  }|  D ]}t|dd}t|||  qd S )NrJ   r   r  r  r  r<   r<   r=   test_trailing_skip/  s    z TestTrimZeros.test_trailing_skipc                 C   sZ   |   D ]L}tj||jd}t|dd}t|dks8J t|dd}t|dksJ qd S )Nr   Br  r   r  )r  r6   Z
zeros_liker   r!   r  )rb   Z_arrr   r  r  r<   r<   r=   test_all_zero5  s    zTestTrimZeros.test_all_zeroc                 C   s    t d}t|}t|| d S r(  )r6   r?   r!   r(   rb   r   r  r<   r<   r=   test_size_zero?  s    
zTestTrimZeros.test_size_zeror   )r   l            r   )r   l            r   )r   l            r   c                 C   s(   t jdd }t|}t|||  d S )NrL   rJ   )r6   r  r!   r(   )rb   r   r  r  r<   r<   r=   test_overflowD  s    zTestTrimZeros.test_overflowc                 C   s$   t g d}t|}t|| d S )N)NrL   N)r6   r   r!   r(   r  r<   r<   r=   test_no_trimO  s    zTestTrimZeros.test_no_trimc                 C   s    t | j }t|tsJ d S r5   )r!   rc   tolistrC  r  r  r<   r<   r=   test_list_to_listT  s    zTestTrimZeros.test_list_to_listN)rs   rt   ru   r6   r   rc   r   rN  r   complexr   r   r$  r  rf   r  r  r  r  r   r  r  r  r  r  r<   r<   r<   r=   r    s(   




r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )
TestExtinsc                 C   s.   t g d}t|dk|}t|g d d S )N)rL   rT   rJ   rL   rJ   rT   rT   rL   )rT   rJ   rJ   rT   rT   )r6   r   r   r(   r~   r<   r<   r=   rf   [  s    zTestExtins.test_basicc                    s   t ttg dddgddg tg d t g dg d t g d	 t td
g  t tdd t g dddg t g d tt	d fdd tddg t ddgd t ddg d S )Nr   TFr   rL   )rL   rH   rT   rJ   rU   rn   rp   )r   rL   r   rL   r   rL   r   rJ   rH   ro   )rL   rJ   rT   rH   rU   ro   rp   rp   rn   )rL   r   rL   r   rL   r   rL   r
  )rn   rJ   r
  rH   rn   ro   r
  z!Cannot insert from an empty arrayc                      s   t  g dg S )N)r   r   r   r   r   rL   r   )r   r<   rc   r<   r=   <lambda>o  r  z'TestExtins.test_place.<locals>.<lambda>Z12Z349)
r+   r   r   r6   r   r(   r?   r7   r/   r_   r|   r<   r  r=   
test_place`  s    
zTestExtins.test_placec                 C   sH   t d}|dk}| }t||}t||d t||| t|| d S )Nr   r   r   )r3   r   r   r   r(   )rb   rc   r  acr   r<   r<   r=   	test_bothv  s    
zTestExtins.test_bothN)rs   rt   ru   rf   r!  r#  r<   r<   r<   r=   r  Y  s   r  r   c                 C   s   |t |  S r5   mathfloorr   r   r<   r<   r=   _foo1  s    r(  r   c                 C   s   |t |  | S r5   r$  )r   r   r  r<   r<   r=   _foo2  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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/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYS )ZTestVectorizec                 C   s4   dd }t |}|g dg d}t|g d d S )Nc                 S   s   | |kr| | S | | S d S r5   r<   rc   r   r<   r<   r=   addsubtract  s    z.TestVectorize.test_simple.<locals>.addsubtractr   rT   ro   r
  rL   rT   rU   rp   rL   ro   rL   rJ   r$   r(   rb   r,  r  r>  r<   r<   r=   test_simple  s    zTestVectorize.test_simplec                 C   s0   dd }t |}|g dd}t|g d d S )Nc                 S   s   | |kr| | S | | S d S r5   r<   r+  r<   r<   r=   r,    s    z.TestVectorize.test_scalar.<locals>.addsubtractr-  rU   )rU   rn   rL   rH   r0  r1  r<   r<   r=   test_scalar  s    zTestVectorize.test_scalarc                 C   s0   t ddd}tdd }||}t|| d S )NrX   rJ   i'  c                 S   s   | S r5   r<   r  r<   r<   r=   r    r  z*TestVectorize.test_large.<locals>.<lambda>)r6   r  r$   r(   )rb   r   r  r   r<   r<   r=   
test_large  s    zTestVectorize.test_largec                 C   sR   t tj}tddtj tjdtj dtj g}||}t|}t|| d S )Nr   r   r  rJ   )r$   r%  cosr6   r   r  r*   )rb   r  argsr1r2r<   r<   r=   
test_ufunc  s
    
(
zTestVectorize.test_ufuncc                 C   sf   ddd}t |}tg d}||}tg d}t|| ||d}tg d}t|| d S )	NrL   c                 S   s   | | S r5   r<   r+  r<   r<   r=   rH    s    z(TestVectorize.test_keywords.<locals>.foor   r   rJ   rS   )rL   r$   r6   r   r(   rb   rH  r  r6  r7  r8  r<   r<   r=   test_keywords  s    


zTestVectorize.test_keywordsc                 C   s:   t ttgd}|tdd}|td}t|| d S Notypesr   r   r$   r(  rN  r6   r7   r(   rb   r  r7  r8  r<   r<   r=    test_keywords_with_otypes_order1  s    z.TestVectorize.test_keywords_with_otypes_order1c                 C   s:   t ttgd}|td}|tdd}t|| d S r=  r@  rA  r<   r<   r=    test_keywords_with_otypes_order2  s    z.TestVectorize.test_keywords_with_otypes_order2c                 C   sT   t ttgd}|td}|tddd}|td}t|| t|| d S )Nr>  r   r   r   r@  rb   r  r7  r8  Zr3r<   r<   r=    test_keywords_with_otypes_order3  s    
z.TestVectorize.test_keywords_with_otypes_order3c                 C   sd   t ttgd}|ddd}|ddd}|d}t|tddd t|tddd t|td d S )Nr>  $@r,  )r  r[   rD  r$   r)  rN  r'   rE  r<   r<   r=   +test_keywords_with_otypes_several_kwd_args1  s    z9TestVectorize.test_keywords_with_otypes_several_kwd_args1c                 C   sR   t ttgd}|dddd}|ddd}t|tdddd t|tddd d S )	Nr>  r,  rG  r[   )r  r   r   rL   rJ   rT   rH  rA  r<   r<   r=   +test_keywords_with_otypes_several_kwd_args2  s
    z9TestVectorize.test_keywords_with_otypes_several_kwd_args2c                 C   s4   dd l }zt|j W n ty.   t Y n0 d S r(  )r  r$   	randrange	ExceptionAssertionError)rb   r  r<   r<   r=   test_keywords_no_func_code  s
    z(TestVectorize.test_keywords_no_func_codec                 C   s   ddd}t |}tg d}||d}tg d}t|| |d|d}t|| ||dd	}tg d
}t|| d S )NrL   c                 S   s   | | S r5   r<   r+  r<   r<   r=   rH    s    z5TestVectorize.test_keywords2_ticket_2100.<locals>.foor   r  r   )r   rc   rJ   r   rS   )rL   r:  r;  r<   r<   r=   test_keywords2_ticket_2100   s    



z(TestVectorize.test_keywords2_ticket_2100c                 C   sr   dd }t j|ddgd}ddg}t||ddgg d	d
 t||ddgg d	d t||ddgg d	 d S )Nc                 S   s.   t |}|d}|r*||  |d }q|S r(  )r  pop)r   p_pr  r<   r<   r=   	mypolyval  s
    
z;TestVectorize.test_keywords3_ticket_2100.<locals>.mypolyvalrR  rL   )excludedrT   ro   r   r   )r   rR  )rR  )r6   r$   r(   )rb   rT  ZvpolyvalZansr<   r<   r=   test_keywords3_ticket_2100  s    z(TestVectorize.test_keywords3_ticket_2100c                 C   s.   t dd }t|ddgddgdddg d S )	Nc                  [   s   d}| D ]}|| | 9 }q|S Nr   r<   )kwr  Z_kr<   r<   r=   r  "  s    z3TestVectorize.test_keywords4_ticket_2100.<locals>.frL   rJ   rT   rH   r+  rn   r0  rb   r  r<   r<   r=   test_keywords4_ticket_2100   s    
z(TestVectorize.test_keywords4_ticket_2100c                 C   s,   t dd }t|ddgddgddg d S )Nc                  W   s
   t | S r5   )r6   r  )r  r<   r<   r=   r  -  s    z3TestVectorize.test_keywords5_ticket_2100.<locals>.frL   rJ   rT   rH   rn   r0  rY  r<   r<   r=   test_keywords5_ticket_2100+  s    
z(TestVectorize.test_keywords5_ticket_2100c                 C   s    dd }t |}t| d d S )Nc                   S   s   dS NrL   r<   r<   r<   r<   r=   rH  4  s    z5TestVectorize.test_coverage1_ticket_2100.<locals>.foorL   r0  rb   rH  r  r<   r<   r=   test_coverage1_ticket_21003  s    z(TestVectorize.test_coverage1_ticket_2100c                 C   s>   dd }t |}t|j|j d}t ||d}t|j| d S )Nc                 S   s   | S )zOriginal documentationr<   r  r<   r<   r=   rH  ;  s    z3TestVectorize.test_assigning_docstring.<locals>.foozProvided documentation)doc)r$   r'   __doc__)rb   rH  r  r_  r<   r<   r=   test_assigning_docstring:  s    z&TestVectorize.test_assigning_docstringc                 C   s`   G dd d}t t| jtdtdd  t t|j| tdtdd  d S )Nc                   @   s   e Zd ZdZdd ZdS )z9TestVectorize.test_UnboundMethod_ticket_1156.<locals>.FoorJ   c                 S   s
   || j  S r5   rO  rl   r<   r<   r=   rI  K  s    z=TestVectorize.test_UnboundMethod_ticket_1156.<locals>.Foo.barN)rs   rt   ru   r   rI  r<   r<   r<   r=   FooH  s   rb  r
  rJ   )r(   r$   rI  r6   r7   )rb   rb  r<   r<   r=   test_UnboundMethod_ticket_1156F  s    z,TestVectorize.test_UnboundMethod_ticket_1156c                 C   sl   t dd }|td}|tdd}t dd }|tdd}|td}t|| t|| d S )Nc                 S   s   | S r5   r<   r  r<   r<   r=   r  U  r  z@TestVectorize.test_execution_order_ticket_1487.<locals>.<lambda>rT   r  c                 S   s   | S r5   r<   r  r<   r<   r=   r  X  r  )r$   r6   r7   r'   )rb   f1Zres1aZres1bf2Zres2bZres2ar<   r<   r=    test_execution_order_ticket_1487S  s    
z.TestVectorize.test_execution_order_ticket_1487c                 C   s$   t dd }d}t||| d S )Nc                 S   s   | S r5   r<   r  r<   r<   r=   r  `  r  z7TestVectorize.test_string_ticket_1892.<locals>.<lambda>Zd0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789)r6   r$   r'   )rb   r  r  r<   r<   r=   test_string_ticket_1892^  s    z%TestVectorize.test_string_ticket_1892c                    sN   dg t  fdd}d|_td}t||||  t d t| d S )Nr   c                    s    d  d7  < | d S )Nr   rL   rJ   r<   r  Z_callsr<   r=   r  h  s    z#TestVectorize.test_cache.<locals>.fTrU   )r$   cacher6   r7   r(   r'   r  rb   r  r   r<   rh  r=   
test_cached  s    
zTestVectorize.test_cachec                 C   s0   t dd }d|_t d}t||| d S )Nc                 S   s   | S r5   r<   r  r<   r<   r=   r  s  r  z+TestVectorize.test_otypes.<locals>.<lambda>r   rU   )r6   r$   r?  r7   r(   rj  r<   r<   r=   test_otypesr  s    
zTestVectorize.test_otypesc                 C   s  t tddgdgf t tddgdgf t tdddgdgf t tddgdgf t td	dgddgf t td
g ddgf t tddgdgf t tddgdgf t tdddgdgf t tddgdgf t tddgddgf t tdg ddgf tt td W d    n1 sV0    Y  tt td W d    n1 s0    Y  tt td W d    n1 s0    Y  d S )Nz(x)->()r  r<   z	(x,y)->()r'  z(x),(y)->()rD  z(x)->(y)z(x)->(y),()z(),(a,b,c),(d)->(d,e))r<   )rc   r   r   )r$  )r$  ez(x )->()z( x , y )->(  )z(x),( y) ->()z(  x)-> (y )  z (x)->( y),( )z*(  ), ( a,  b,c )  ,(  d)   ->   (d  ,  e)z
(x)(y)->()z	(x),(y)->z
((x))->(x))r'   nfbZ_parse_gufunc_signaturer+   r_   r|   r<   r<   r=   test_parse_gufunc_signaturex  sP    













*
*
z)TestVectorize.test_parse_gufunc_signaturec                 C   s8   dd }t |dd}|g dg d}t|g d d S )Nc                 S   s   | |kr| | S | | S d S r5   r<   r+  r<   r<   r=   r,    s    z8TestVectorize.test_signature_simple.<locals>.addsubtractz	(),()->()	signaturer-  r.  r/  r0  r1  r<   r<   r=   test_signature_simple  s    z#TestVectorize.test_signature_simplec                 C   s:   dd }t |dd}|ddgddgg}t|ddg d S )	Nc                 S   s   |   S r5   r   r  r<   r<   r=   r     s    z4TestVectorize.test_signature_mean_last.<locals>.meanz(n)->()rp  rL   rT   rJ   rH   r0  )rb   r   r  r>  r<   r<   r=   test_signature_mean_last  s    z&TestVectorize.test_signature_mean_lastc                 C   sB   dd }t |dd}|ddgddgg}t|d	dgd	dgg d S )
Nc                 S   s   | |    S r5   rs  r  r<   r<   r=   center  s    z3TestVectorize.test_signature_center.<locals>.center(n)->(n)rp  rL   rT   rJ   rH   r[   r0  )rb   ru  r  r>  r<   r<   r=   test_signature_center  s    z#TestVectorize.test_signature_centerc                 C   s^   t dd dd}|g d}tt|to2t|dk t|d g d t|d g d d S )	Nc                 S   s   | | fS r5   r<   r  r<   r<   r=   r    r  z:TestVectorize.test_signature_two_outputs.<locals>.<lambda>	()->(),()rp  r   rJ   r   rL   )r$   r&   rC  r  r  r(   rb   r  r>  r<   r<   r=   test_signature_two_outputs  s
    z(TestVectorize.test_signature_two_outputsc                 C   s   t tjdd}|ddgg d}t|g dg dg |ddgggg d}t|g dg dggg |ddgddggg d}t|g dg dgg dg dgg |ddgg dg dg}t|g dg dgg dg dgg d S )	Nz(a),(b)->(a,b)rp  rL   rJ   r   r  r   r   )r$   r6   r9   r(   ry  r<   r<   r=   test_signature_outer  s    z"TestVectorize.test_signature_outerc                 C   sX   t dd dd}|g d}t|ddg |g dg dg}t|ddgdd	gg d S )
Nc                 S   s   | d d S Nr[   r<   r  r<   r<   r=   r    r  z<TestVectorize.test_signature_computed_size.<locals>.<lambda>z(n)->(m)rp  r   rL   rJ   r   rT   r0  ry  r<   r<   r=   test_signature_computed_size  s
    z*TestVectorize.test_signature_computed_sizec                 C   sN   ddd}t |ddhd}t|g dg d t|g dd	d
g d d S )NrL   c                 S   s   | | S r5   r<   r+  r<   r<   r=   rH    s    z2TestVectorize.test_signature_excluded.<locals>.foo()->()r   )rq  rU  r   r   r   rO  )rL   r0  r]  r<   r<   r=   test_signature_excluded  s    
z%TestVectorize.test_signature_excludedc                 C   sD   t dd ddgd}|g d}t|jtd t|g d d S )Nc                 S   s   | S r5   r<   r  r<   r<   r=   r    r  z5TestVectorize.test_signature_otypes.<locals>.<lambda>rv  r   rq  r?  r   )r$   r'   r   r6   r(   ry  r<   r<   r=   test_signature_otypes  s    z#TestVectorize.test_signature_otypesc                 C   s   t tjdd}ttd |ddg W d    n1 s:0    Y  ttd |dd W d    n1 sn0    Y  ttd" |ddgg d W d    n1 s0    Y  t tjd	d}ttd |dd W d    n1 s0    Y  d S )
Nz(n),(n)->(n)rp  zwrong number of positionalrL   rJ   zdoes not have enough dimensions$inconsistent size for core dimensionr   r~  )r$   operatorr8   r/   r   r_   rY  r<   r<   r=   test_signature_invalid_inputs  s    *(0z+TestVectorize.test_signature_invalid_inputsc                 C   s   t dd dd}ttd |g d W d    n1 s<0    Y  t dd dd}ttd	 |d
 W d    n1 s~0    Y  t dd dd}ttd	 |d
dg W d    n1 s0    Y  d S )Nc                 S   s   | d d S r|  r<   r  r<   r<   r=   r    r  z>TestVectorize.test_signature_invalid_outputs.<locals>.<lambda>rv  rp  r  r   c                 S   s   | S r5   r<   r  r<   r<   r=   r    r  rx  zwrong number of outputsrL   c                 S   s   | | fS r5   r<   r  r<   r<   r=   r    r  r~  rJ   )r$   r/   r_   rY  r<   r<   r=   test_signature_invalid_outputs  s    *&z,TestVectorize.test_signature_invalid_outputsc                 C   s^  t dd }t jddgtd}ttd || W d    n1 sH0    Y  d|_t||| t jdd d	d
}ttd || W d    n1 s0    Y  t jdd d	dd}t||| t jdd ddd}t||| t jdd dd
}t||j|j t jdd ddd}ttd || W d    n1 sP0    Y  d S )Nc                 S   s   | S r5   r<   r  r<   r<   r=   r    r  z5TestVectorize.test_size_zero_output.<locals>.<lambda>r   rU   r   r?  r   c                 S   s   | S r5   r<   r  r<   r<   r=   r    r  r~  rp  c                 S   s   | S r5   r<   r  r<   r<   r=   r    r  r  c                 S   s   | S r5   r<   r  r<   r<   r=   r    r  rv  c                 S   s   | S r5   r<   r  r<   r<   r=   r    r  c                 S   s   | gS r5   r<   r  r<   r<   r=   r    r  z()->(n)znew output dimensions)	r6   r$   r?   intr/   r_   r?  r(   r   rj  r<   r<   r=   test_size_zero_output  s$    &&z#TestVectorize.test_size_zero_outputc                 C   s   G dd dt j}t g dg dg dg|}t g dg dg dg|}t jt jd	d
}|||}tt|| t|g dg dg dg t dd }|||}tt|| t|||  d S )Nc                   @   s   e Zd ZdS )z/TestVectorize.test_subclasses.<locals>.subclassNr   r<   r<   r<   r=   r     s   r   )r   r   r   r0  )r   r   r   r   )r   r   r   r   z(m,m),(m)->(m)rp  )r   r   r   )r   r   r   )r   r   r   c                 S   s   | | S r5   r<   r'  r<   r<   r=   r  +  r  z/TestVectorize.test_subclasses.<locals>.<lambda>)r6   r   r   r   r$   matmulr'   r   )rb   r   r  r  Zmatvecr>  Zmultr<   r<   r=   r     s     
"

zTestVectorize.test_subclassesc                 C   s    t jdd }|jdksJ d S )Nc                 S   s   | | S r5   r<   r+  r<   r<   r=   re  2  s    z#TestVectorize.test_name.<locals>.f2re  )r6   r$   rs   )rb   re  r<   r<   r=   	test_name0  s    
zTestVectorize.test_namec                 C   s0   t dd }|g dg d}t|g d d S )Nc                 S   s   | |kr| | S | | S d S r5   r<   r+  r<   r<   r=   r,  9  s    z1TestVectorize.test_decorator.<locals>.addsubtractr-  r.  r/  r0  )rb   r,  r>  r<   r<   r=   test_decorator8  s    
zTestVectorize.test_decoratorc                 C   s*   t dd }tjjdk r&|jdks&J d S )Nc                 S   s   | S )	Docstringr<   r  r<   r<   r=   r  D  s    z'TestVectorize.test_docstring.<locals>.frJ   r  )r$   sysr   optimizer`  rY  r<   r<   r=   test_docstringC  s    
zTestVectorize.test_docstringc                 C   s0   dd }t |d}t|}|ddks,J d S )Nc                 S   s   | | S r5   r<   r'  r<   r<   r=   rH  M  s    z'TestVectorize.test_partial.<locals>.foorT   rL   rH   )r   r6   r$   )rb   rH  rI  Zvbarr<   r<   r=   test_partialL  s    

zTestVectorize.test_partialc                 C   sT   t ddgddd }|g d}t|jtd t|g d |jdksPJ d S )Nrv  r   r  c                 S   s   | S r5   r<   r  r<   r<   r=   r  U  s    z8TestVectorize.test_signature_otypes_decorator.<locals>.fr   r  )r$   r'   r   r6   r(   rs   ry  r<   r<   r=   test_signature_otypes_decoratorT  s    
z-TestVectorize.test_signature_otypes_decoratorc                 C   s8   t t tjdd}W d    n1 s*0    Y  d S )NrT   )Zpyfuncr+   r   r6   r$   )rb   Ar<   r<   r=   test_bad_input^  s    
zTestVectorize.test_bad_inputc                 C   s>   t t" tddd }W d    n1 s00    Y  d S )Nstringc                   S   s   dS )NrI  r<   r<   r<   r<   r=   rH  d  s    z+TestVectorize.test_no_keywords.<locals>.foor  )rb   rH  r<   r<   r=   test_no_keywordsb  s    
zTestVectorize.test_no_keywordsc                 C   s0   t dd dg}|dg}t|jtd d S )Nc                 S   s   | S r5   r<   r  r<   r<   r=   r  l  r  z?TestVectorize.test_positional_regression_9477.<locals>.<lambda>r   rJ   )r$   r'   r   r6   ry  r<   r<   r=   test_positional_regression_9477h  s    
z-TestVectorize.test_positional_regression_9477c                 C   s:   d}t jg ddd}tt jdd d|gd|| d S )Nzdatetime64[ns])z
2024-01-01z
2024-01-02z
2024-01-03r   c                 S   s   | S r5   r<   r  r<   r<   r=   r  t  r  z8TestVectorize.test_datetime_conversion.<locals>.<lambda>z(i)->(j)r  )r6   r   r(   r$   )rb   Zotyper   r<   r<   r=   test_datetime_conversionp  s    
z&TestVectorize.test_datetime_conversionN)/rs   rt   ru   r2  r3  r4  r9  r<  rB  rC  rF  rI  rJ  rN  rP  rV  rZ  r[  r^  ra  rc  rf  rg  rk  rl  ro  rr  rt  rw  rz  r{  r}  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r<   r<   r<   r=   r*    sX   

"		
r*  c                   @   sL   e Zd ZG dd dZejje ddejddej	fdgdd	 Z
d
S )	TestLeaksc                   @   s$   e Zd ZdZdd Zedd ZdS )zTestLeaks.ArL  c                 G   s   dS r(  r<   rb   r6  r<   r<   r=   bound|  s    zTestLeaks.A.boundc                  G   s   dS r(  r<   )r6  r<   r<   r=   unbound  s    zTestLeaks.A.unboundN)rs   rt   ru   itersr  staticmethodr  r<   r<   r<   r=   r  y  s   r  Python lacks refcountsreasonz
name, incrr  )r  r   c           	      C   s   dd l }t| j|}|  zt|}t| jjD ]2}|  }t	t||dd|_
|
td}q4d }tt|||  tdD ]}|  qtt|| W |  n
|  0 d S )Nr   rL   r   rU   )gcr	  r  disabler  getrefcountra   r  r6   Z
frompyfuncr  r7   r'   Zcollectenable)	rb   r
  incrr  ZA_funcrefcountr   rc   r  r<   r<   r=   test_frompyfunc_leaks  s    

zTestLeaks.test_frompyfunc_leaksN)rs   rt   ru   r  r   r  skipifr1   r  r  r  r<   r<   r<   r=   r  x  s   
r  c                   @   sz   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ejjdddd ZdS )TestDigitizec                 C   s2   t dd}t dd}tt||t d d S )Nr  rU   rT  r   r6   r7   r(   r   rb   r   binsr<   r<   r=   test_forward  s    zTestDigitize.test_forwardc                 C   s6   t ddd}t ddd}tt||t d d S )NrU   r  r[   rT  r   r  r  r<   r<   r=   test_reverse  s    zTestDigitize.test_reversec                 C   s:   t d}t| | d}ttt||dk d S )Nr   r   r3   r6   r  r  r  r&   r   r   )rb   r   binr<   r<   r=   test_random  s    zTestDigitize.test_randomc                 C   sF   g d}g d}g d}t t||| g d}t t||d| d S )N)rL   rU   rH   r   rn   r   r   )rL   rU   r   )rL   rJ   rL   rT   rJ   rT   r   )r   rL   rL   rJ   rJ   rT   r   T)r(   r   )rb   r   r  Zdefault_answerZright_answerr<   r<   r=   test_right_basic  s    zTestDigitize.test_right_basicc                 C   s4   t dd}t dd}tt||dt d d S )Nr  rU   rH   Tr   r  r  r<   r<   r=   test_right_open  s    zTestDigitize.test_right_openc                 C   s8   t ddd}t ddd}tt||dt d d S )NrU   r  r[   rH   Tr   r  r  r<   r<   r=   test_right_open_reverse  s    z$TestDigitize.test_right_open_reversec                 C   s<   t d}t| | d}ttt||ddk d S )Nr   Tr  r  r<   r<   r=   test_right_open_random  s    z#TestDigitize.test_right_open_randomc                 C   s   g d}g d}t t||dg d t t||dg d g d}t t||dg d t t||dg d	 g d
}t t||dg d t t||dg d g d}ttt|| g d}ttt|| d S )N)r[   r   rL   rJ   r   F)r   rJ   rT   rT   T)r   r   rJ   rT   r   )rT   rJ   r   r   )rT   rT   rJ   r   r   )r   r   rH   rH   )r   r   r   rH   r   )rL   rL   r   rL   )r(   r   r+   r_   r  r<   r<   r=   test_monotonic  s    zTestDigitize.test_monotonicc                 C   s:   g d}g d}t tt|| || }}t tt|| d S )N)rL   rJ   y      @      ?r   )r+   r   r   r  r<   r<   r=   test_casting_error  s
    
zTestDigitize.test_casting_errorc                 C   sh   G dd dt j}t d|}t dd|}ttt||d|  ttt||d|  d S )Nc                   @   s   e Zd ZdS )z(TestDigitize.test_return_type.<locals>.ANr   r<   r<   r<   r=   r    s   r  rU   rL   rT   FT)r6   r   r7   r   r&   rC  r   )rb   r  rc   r   r<   r<   r=   r    s
    zTestDigitize.test_return_typec                 C   s&   d}t t||d |d gd d S Nl          rL   r'   r6   r   rF  r<   r<   r=   test_large_integers_increasing  s    z+TestDigitize.test_large_integers_increasingz9gh-11022: np._core.multiarray._monoticity loses precisionr  c                 C   s&   d}t t||d |d gd d S r  r  rF  r<   r<   r=   test_large_integers_decreasing  s    z+TestDigitize.test_large_integers_decreasingN)rs   rt   ru   r  r  r  r  r  r  r  r  r  r  r  r   r  Zxfailr  r<   r<   r<   r=   r    s   	r  c                   @   s   e Zd Zdd Zdd ZdS )
TestUnwrapc                 C   sH   t tdddtj  gddg tttttdd tjk  d S )NrL   rJ   r   r,  )r(   r"   r6   r  r&   r   r   r3   r|   r<   r<   r=   r2    s     zTestUnwrap.test_simplec                 C   s   t tddgddddg tttttdd dddk  tg d}t|d}t t|dd| tg d	}t|d
}t|d
d}t |g d t|d
dd}t |g d	 |j	|j	ksJ d S )NrL   i     periodrJ   r     )r   K         r  )r   r  r  r  r  i     )r   r  r  r  r  r~     )r  Zdiscont)
r(   r"   r&   r6   r   r   r3   r   modr   )rb   Z
simple_seqZwrap_seqZ
uneven_seqZwrap_unevenZ
no_discontZ
sm_discontr<   r<   r=   test_period  s    &zTestUnwrap.test_periodN)rs   rt   ru   r2  r  r<   r<   r<   r=   r    s   r  O
AllIntegerFloatM)r   rL   r   c                   @   sf   e Zd ZeeddddZeeddddZeeddddZeeddd	d
ZeeddddZ	dS )TestFilterwindowsN)r   r  returnc                 C   s   t j||dd }t|}|dkr*t j}nt |jt j}|j|ksHJ t|t| |dk rpt|t g  n0|dkrt|t 	d nt
t j|dddd d S )	Nr   r<   r  rL   r   rw         @rH   )r6   r   r   r   r   r   r'   r   r(   r`   r)   r   rb   r   r  Zscalarr   Z	ref_dtyper<   r<   r=   test_hanning  s    zTestFilterwindows.test_hanningc                 C   s   t j||dd }t|}|dkr*t j}nt |jt j}|j|ksHJ t|t| |dk rpt|t g  n0|dkrt|t 	d nt
t j|dddd d S )	Nr   r<   r  rL   r   rw   g(\@rH   )r6   r   r   r   r   r   r'   r   r(   r`   r)   r   r  r<   r<   r=   test_hamming,  s    zTestFilterwindows.test_hammingc                 C   s   t j||dd }t|}|dkr*t j}nt |jt j}|j|ksHJ t|t| |dk rpt|t g  n0|dkrt|t 	d nt
t j|dddd d S )	Nr   r<   r  rL   r   rw   g^)@rH   )r6   r   r	   r   r   r   r'   r   r(   r`   r)   r   r  r<   r<   r=   test_bartlettA  s    zTestFilterwindows.test_bartlettc                 C   s   t j||dd }t|}|dkr*t j}nt |jt j}|j|ksHJ t|t| |dk rpt|t g  n0|dkrt|t 	d nt
t j|dddd d S )	Nr   r<   r  rL   r   rw   g=
ףp=@rH   )r6   r   r
   r   r   r   r'   r   r(   r`   r)   r   r  r<   r<   r=   test_blackmanV  s    zTestFilterwindows.test_blackmanc                 C   s   t j||dd }t|d}|dkr,t j}nt |jt j}|j|ksJJ t|t| |dk rrt|t g  n0|dkrt|t 	d nt
t j|dddd d S )	Nr   r<   r   r  rL   rw   r   r  )r6   r   r   r   r   r   r'   r   r(   r`   r)   r   r  r<   r<   r=   test_kaiserk  s    
zTestFilterwindows.test_kaiser)
rs   rt   ru   strr  r  r  r  r  r  r<   r<   r<   r=   r    s
   r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestTrapezoidc                 C   sH   t ddd}tt d|d  t dt j  dd}t|dd d S )	Nr   r  r  rJ   )r  rL   rp   )r6   r7   r    r  r  r  r)   )rb   r   r>  r<   r<   r=   r2    s    *zTestTrapezoid.test_simplec                 C   s&  t ddd}t ddd}t ddd}t ||d |d   }|d  d  < |d  d  < t ||d |d   }|d  d  < |d  d  < t ||d |d   }|d  d  < |d  d  < |d d d d f |d d d d f  |d d d d f  }||d d d d f  jdd}||d d d d f  jdd}	||d d d d f  jdd}
t||d d d d f dd	}t|| t||d d d d f dd	}t||	 t||d d d d f dd	}t||
 t||dd	}t|| t||dd	}t||	 t||dd	}t||
 d S )
Nr   rL   rT   rJ   rn   rY   r[   rw   )r   rx   )r6   r  	ones_liker   r    r)   )rb   r   r   r  ZwxZwyZwzqZqxZqyZqzr>  r<   r<   r=   	test_ndim  s8    6




zTestTrapezoid.test_ndimc                 C   s   t d}|| }|dk}t jj||d}d}tt||| t jj||d}tt||| t jj||d}tt||| d S )NrU   rJ   r  g      *@)r6   r7   r   r   r)   r    )rb   r   r   r  Zymr>  Zxmr<   r<   r=   r    s    
zTestTrapezoid.test_maskedN)rs   rt   ru   r2  r  r  r<   r<   r<   r=   r    s   %r  c                   @   s   e Zd Zdd Zdd ZdS )TestSincc                 C   s6   t tddk ttddd}t|t|d d S )Nr   rL   r[   r,  rp   )r&   r   r6   r  r*   r   rb   r   r<   r<   r=   r2    s    zTestSinc.test_simplec                 C   sF   ddg}t t|}t t|}t t|}t|| t|| d S )Nr   r   )r   r6   r   r  r  r(   )rb   r   r   r   r   r<   r<   r=   test_array_like  s    
zTestSinc.test_array_likeN)rs   rt   ru   r2  r  r<   r<   r<   r=   r    s   r  c                   @   s   e Zd Zdd ZdS )
TestUniquec                 C   s   t g d}tt t|g dk ttt g dt dgk g d}tt t|g dk t g d}tt t|g dk d S )	N)	rH   rT   rJ   rL   rL   rJ   rT   rH   r   )r   rL   rJ   rT   rH   )rL   rL   rL   rL   rL   rL   )widgethamrH  rI  rH  r  )rI  rH  r  r  )      @      @r        ?      $@r   r  )r  r  r  r   )r6   r   r&   r   r#   rF  r<   r<   r=   r2    s    "zTestUnique.test_simpleN)rs   rt   ru   r2  r<   r<   r<   r=   r    s   r  c                   @   s   e Zd Zdd Zdd ZdS )TestCheckFinitec                 C   sJ   g d}ddt jg}ddt jg}t | ttt j| ttt j| d S )Nr   rL   rJ   )r6   infr"  asarray_chkfiniter+   r_   r   r<   r<   r=   r2    s    
zTestCheckFinite.test_simplec                 C   s.   g d}t j|dt jd}t|jt jk d S )Nr   r   )r   r   )r6   r  r   r&   r   rl   r<   r<   r=   test_dtype_order  s    z TestCheckFinite.test_dtype_orderN)rs   rt   ru   r2  r  r<   r<   r<   r=   r    s   r  c                	   @   s   e Zd Zeg dg dg dgZeg dg dg dgZeg dg dg d	gZeg d
g dg dg dg dg dg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ejd ejejejejgd!d" Zd#S )$TestCorrCoef)g^?g.{<?g$,?)g4?gp)?gJG?)gY?g?gވ0v?)gة?gBFU?g G)t?)g3TB?gL\?gA?)g>
?gqFE`?g5?)r   ޛ?r@)r  r   p]4?)r  r  r   )r   r  r  ?'L?(8?4V}?)r  r   r  w{,H5?jS,?)r  r  r   )h?5#A?)r  r  r  r   toBC,)r  r  r  r  r   @02v?)r  r  r  r  r  r   c                 C   s*   t tg dg dddgddgg d S )Nr   )rL   r   rL   r         )r)   r6   r   r|   r<   r<   r=   test_non_array	  s    zTestCorrCoef.test_non_arrayc                 C   sd   t | j}t|| j ttt|dk t | j| j}t|| j	 ttt|dk d S rW  )
r   r  r)   r  r&   r6   r   r  r  r  )rb   Ztgt1Ztgt2r<   r<   r=   r2  	  s    
zTestCorrCoef.test_simplec                 C   s   t  }td ttt| jdd |t tt| jdd| j	 tt| j| j
dd| j tt| jdd| j	 tt| j| j
dd| j W d    n1 s0    Y  d S )Nr3  r[   ZddofrT   )r0   r6  simplefilterr.   DeprecationWarningr   r  filterr)   r  r  r  rb   supr<   r<   r=   	test_ddof	  s    

zTestCorrCoef.test_ddofc                 C   s|   t  b}td ttt| j| jdd ttt| jdd |t t	t| jdd| j
 W d    n1 sn0    Y  d S )Nr3  rL   r   )Zbias)r0   r6  r  r.   r  r   r  r  r  r)   r  r  r<   r<   r=   	test_bias	  s    

zTestCorrCoef.test_biasc                 C   sZ   t g dg dg}t|}t ddgddgg}t|| tt t |dk d S Nr   r  y               @r&  r   r   r  )r6   r   r   r,   r&   r   r  )rb   r   r  rv  r<   r<   r=   test_complex%	  s
    
zTestCorrCoef.test_complexc                 C   sH   t g dg}t g dg}tt ||t ddgddgg d S r  )r6   r   r,   r   rb   r   r   r<   r<   r=   test_xy,	  s    zTestCorrCoef.test_xyc                 C   s   t jdd t dt tttg tj tttg 	ddtg 	dd tttg 	ddttjtjgtjtjgg W d    n1 s0    Y  d S NTr1  r3  r   rJ   )
r6  r7  r  RuntimeWarningr(   r   r6   r   r"  rq   r|   r<   r<   r=   
test_empty1	  s    zTestCorrCoef.test_emptyc                 C   s|   ddgddgg}t jdd t|}W d    n1 s:0    Y  t|t ddgddgg tt t |dk d S )Ng0.++g}Ô%ITraise)r   r   r  )r6   Zerrstater   r*   r   r&   r   r  )rb   r   r   r<   r<   r=   test_extreme:	  s
    &zTestCorrCoef.test_extreme	test_typec                 C   s*   | j |}t||d}||jks&J d S Nr   )r  r   r   r   )rb   r  Zcast_Ar  r<   r<   r=   test_corrcoef_dtypeA	  s    z TestCorrCoef.test_corrcoef_dtypeN)rs   rt   ru   r6   r   r  r  r  r  r  r2  r  r   r  r  r  r
  r   r  r  halfsingledouble
longdoubler  r<   r<   r<   r=   r    sJ   	
	r  c                   @   s\  e Zd ZeddgddgddggjZeddgddggZejg dddZeg dZ	ed	gdgdgdgdgd
ggjZ
eddgddggZejdejdZeg dZeddgddggZedZeg 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ejd'ej ej!ej"ej#gd(d) Z$d*S )+TestCovr   rJ   rL   r   r  )r   r   r   )ndmin)rL   rH   rL   r   r   皙?gٿrT   r   )r   r   r   gUUUUUU?gUUUUUU)g&S:?go_?g#~j?gZӼ?gQ|?c                 C   s   t t| j| j d S r5   )r,   r   x1r  r|   r<   r<   r=   rf   U	  s    zTestCov.test_basicc                 C   sV   t g dg dg}t ddgddgg}tt|| tt|t dd| d S )Nr   r  r   r   r  rT   aweights)r6   r   r,   r   r`   )rb   r   r  r<   r<   r=   r  X	  s    zTestCov.test_complexc                 C   sF   t g dg}t g dg}tt||t ddgddgg d S r  )r6   r   r,   r   r  r<   r<   r=   r  ^	  s    zTestCov.test_xyc                 C   s   t jdd t dt tttg tj tttg 	ddtg 	dd tttg 	ddttjtjgtjtjgg W d    n1 s0    Y  d S r  )
r6  r7  r  r  r(   r   r6   r   r"  rq   r|   r<   r<   r=   r  c	  s    zTestCov.test_emptyc                 C   sn   t jddN t dt tt| jddttj	tj	 gtj	 tj	gg W d    n1 s`0    Y  d S )NTr1  r3  rU   r  )
r6  r7  r  r  r(   r   r  r6   r   r  r|   r<   r<   r=   test_wrong_ddofl	  s    zTestCov.test_wrong_ddofc                 C   sJ   t t| jt| jdd tg d}t t| j|t| j|dd d S )NF)Zrowvar)g+?g4@?g&S?go_?gJ4?)r,   r   x3r6   r   rb   r   r<   r<   r=   test_1D_rowvars	  s    zTestCov.test_1D_rowvarc                 C   s$   t t| jddtj| jdd d S )NrL   r  )r,   r   r  r6   varr|   r<   r<   r=   test_1D_variancex	  s    zTestCov.test_1D_variancec                 C   s   t t| j| jdt| j t t| j| jd| j t t| j| jd| j | jd }t	t
t| j|d tjdtjd}t	tt| j|d tjdtjd}t	tt| j|d dtjdtjd }t	tt| j|d d S )N)fweightsr   rJ   rT   r   rJ   r[   rT   )r,   r   r  frequencies
x2_repeatsr  r  unit_frequenciesr  r+   r   r6   r`   r)  RuntimeErrorr_   )rb   Znonintr  r<   r<   r=   test_fweights{	  s"    
zTestCov.test_fweightsc                 C   s   t t| j| jd| j t t| jd| j dt| j| jd t t| j| jd| j td}t	t
t| j|d td}t	t
t| j|d dtd }t	tt| j|d d S )Nr  r   r  rJ   r  rT   )r,   r   r  r   r  unit_weightsr  r6   r`   r+   r#  r_   r  r<   r<   r=   test_aweights	  s    

zTestCov.test_aweightsc                 C   s   t t| j| j| jdt| j t t| j| j| jd| j t t| j| j| jd| j	 t t| j| j| j
d| j t t| j| jd| j
 dt| j| j
d t t| j| j| jd| j	 d S )N)r  r  r   r  )r,   r   r  r   r%  r!  r  r  r"  r  r   r  r|   r<   r<   r=   test_unit_fweights_and_aweights	  s<    z'TestCov.test_unit_fweights_and_aweightsr  c                 C   s*   | j |}t||d}||jks&J d S r  )r  r   r   r   )rb   r  Zcast_x1r  r<   r<   r=   test_cov_dtype	  s    zTestCov.test_cov_dtypeN)%rs   rt   ru   r6   r   r   r  r  r  r   r!  r  r`   r)  r"  r   r  r%  r  rf   r  r  r  r  r  r  r$  r&  r'  r   r  r  r  r  r  r  r(  r<   r<   r<   r=   r  H	  s.   $
	r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )Test_I0c              
   C   s   t tdtd tg d}tg d}t t|| t t| | tddgddgd	d
gddgddgg}t t|tddgddgddgddgddgg tdg}t|jd ttdgtdg d S )Nr   gǒ#?)gC7?gmM?g3a,?g$WV?ۏ?rU  )gֿN^?gE ?g閡1?g%m? ?gDn@g>@v?guͥ?gVX˳?gua&?gB-sJ?g-^?g_V?gX.?gVaX?gj?gp?g~-@?gD/b?gݦ?g,Y1ؔ?g[!?gQL?gWsU+?g@?gfxw?r   r  r   )r)   r   r6   r   r'   rA   r(   )rb   r  r  r  Zi0_0r<   r<   r=   r2  	  s4    

zTest_I0.test_simplec                    sV   t d G  fddd}tt | |s2J t  }t | }t|| d S )NrH   c                       s   e Zd Z jZdd ZdS )z*Test_I0.test_non_array.<locals>.array_likec                 S   s   | S r5   r<   )rb   r   contextZreturn_scalarr<   r<   r=   __array_wrap__	  s    z9Test_I0.test_non_array.<locals>.array_like.__array_wrap__N)rs   rt   ru   Z__array_interface__r+  r<   r  r<   r=   
array_like	  s   r,  )r6   r7   rC  r  r   r(   )rb   r,  r  r  r<   r  r=   r  	  s    

zTest_I0.test_non_arrayc                 C   sH   t ddg}tjtdd t|}W d    n1 s:0    Y  d S )Nr   y      ?       @z#i0 not supported for complex valuesr   )r6   r   r   r   r   r   )rb   rc   r  r<   r<   r=   r  	  s    zTest_I0.test_complexN)rs   rt   ru   r2  r  r  r<   r<   r<   r=   r)  	  s   r)  c                   @   s   e Zd Zdd Zdd ZdS )
TestKaiserc                 C   s|   t ttdd ttddtg  ttddtddg ttddtg d ttddtg d	 d S )
NrL   r   r   rJ    oF?rU   )r.  vT=?r   r/  r.  gg?)?YJ?r   r1  r0  )r&   r6   isfiniter   r)   r   r|   r<   r<   r=   r2  	  s    



zTestKaiser.test_simplec                 C   s   t dd d S )NrT   rH   )r   r|   r<   r<   r=   test_int_beta	  s    zTestKaiser.test_int_betaN)rs   rt   ru   r2  r3  r<   r<   r<   r=   r-  	  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d Z
dd Zdd Zdd ZdS )TestMeshgridc              	   C   sj   t g dg d\}}t|tg dg dg dg dg t|tg dg dg dg dg d S )Nr   rH   rU   ro   rp   r   )rU   rU   rU   )ro   ro   ro   )rp   rp   rp   r   r(   r6   r   rb   XYr<   r<   r=   r2  	  s    zTestMeshgrid.test_simplec                 C   s&   t g d\}t|tg d d S )Nr`  r6  )rb   r8  r<   r<   r=   test_single_input
  s    zTestMeshgrid.test_single_inputc                 C   s*   g }t g t|  t g t|ddi d S )Nr   F)r(   r   r  r<   r<   r=   test_no_input

  s    zTestMeshgrid.test_no_inputc                 C   s   g d}g d}t ||dd\}}t|tg dg dg dg t|tg dg dg dg dd	g}tt ||d
 jdk tt ||ddd
 jdk tt |||d
 jdk tt |||ddd
 jdk ttt ||dd d S )Nr   r5  ijZindexingr   )rJ   rJ   rJ   rJ   )rT   rT   rT   rT   rn   r
  r   r  rT   rH   )rH   rT   rJ   )rT   rH   rJ   Znotvalid)r   r(   r6   r   r&   rA   r+   r_   )rb   r   r   r8  r9  r  r<   r<   r=   test_indexing
  s"    zTestMeshgrid.test_indexingc                 C   sT   t g dg ddd\}}t|tg dg t|tdgdgdgdgg d S )	Nr   r5  TsparserH   rU   ro   rp   r6  r7  r<   r<   r=   test_sparse#
  s    zTestMeshgrid.test_sparsec                 C   s   t ttg dg ddd d S )Nr   r5  r<  )r  )r+   r   r   r|   r<   r<   r=   test_invalid_arguments(
  s    z#TestMeshgrid.test_invalid_argumentsc                 C   s   t jddt jd}t jddt jd}t ||\}}t|j|jk t|j|jk t j||dd\}}t|j|jk t|j|jk t j||dd\}}t|j|jk t|j|jk d S )Nr   r   r   rL  T)r   r@  )r6   r7   r   r   r   r&   r   )rb   r   r   r8  r9  r<   r<   r=   r  /
  s    zTestMeshgrid.test_return_typec                 C   sr   t ddg}t ddg}t j||ddd\}}d|dd d f< t|dd d f d t|d	d d f | d S )
Nr  r  gffffff
@g@FT)rA  r   r   rL   )r6   r   r   r'   )rb   r8  r9  r   r   r<   r<   r=   test_writebackG
  s    zTestMeshgrid.test_writebackc                 C   sh   t jdd tddD  \}}}}}d}t|j| t|j| t|j| t|j| t|j| d S )Nc                 s   s   | ]}d g| V  qdS )r   Nr<   r   r   r<   r<   r=   r  R
  r  z-TestMeshgrid.test_nd_shape.<locals>.<genexpr>rL   ro   )rJ   rL   rT   rH   rU   )r6   r   ra   r'   rA   )rb   rc   r   r   r$  rm  Zexpected_shaper<   r<   r=   test_nd_shapeQ
  s    $zTestMeshgrid.test_nd_shapec                 C   sp   t dgddgg d\}}}t|g dgg dgg t|g dgg dgg t|g dgg dgg d S )Nr   rL   rJ   rS   r   r   rI   r6   r   r'   r   r<   r<   r=   test_nd_valuesZ
  s    zTestMeshgrid.test_nd_valuesc                 C   sn   t jdgddgg ddd\}}}t|g dg dgg t|g dg d	gg t|g dg dgg d S )
Nr   rL   rJ   rS   r<  r=  r   r   rI   rG  r   r<   r<   r=   test_nd_indexing`
  s    "zTestMeshgrid.test_nd_indexingN)rs   rt   ru   r2  r:  r;  r?  rB  rC  r  rD  rF  rH  rI  r<   r<   r<   r=   r4  	  s   
	r4  c                   @   sT   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S )TestPiecewisec                 C   s4  t ddgddgdg}t|ddg t ddgddggdg}t|ddg t ddgtddgdg}t|ddg t ddgtddgdg}t|ddg t ddgtddggdg}t|ddg t ddgddggdd g}t|ddg ttdt ddgddggg  ttdt ddgddggg d	 d S )
Nr   TFrL   c                 S   s   dS r|  r<   r  r<   r<   r=   r  ~
  r  z+TestPiecewise.test_simple.<locals>.<lambda>r[   z1 or 2 functions are expectedr   )r   r(   r6   r   r/   r_   rF  r<   r<   r=   r2  i
  s$    zTestPiecewise.test_simplec                 C   s2   t ddgddgddggddg}t|ddg d S )NrL   rJ   TFrT   rH   r   r(   rF  r<   r<   r=   test_two_conditions
  s     z!TestPiecewise.test_two_conditionsc                 C   s"   t dg dg d}t|d d S )NrT   )TFF)rH   rJ   r   rH   )r   r'   rF  r<   r<   r=   $test_scalar_domains_three_conditions
  s    z2TestPiecewise.test_scalar_domains_three_conditionsc                 C   sN   t ddgddgdg}t|ddg t ddgddgddg}t|ddg d S )NrL   rJ   TFr   rT   rK  rF  r<   r<   r=   test_default
  s    zTestPiecewise.test_defaultc                 C   s   t d}t||dkddg}t|jdk t|dk d}t|ddgddg}t|jdk t|dk t|g dg d	}t|d d S )
NrT   rH   r   rU   TFrL   r  r   )r6   r   r   r&   r   r(   r  r<   r<   r=   rA  
  s    
zTestPiecewise.test_0dc                 C   s   d}t ||dk|dkgddg}t|d d}t ||dk|dk|dk |dkgg d}t|d ttdt ||dk|dkgdg ttdt ||dk|dkgg d	 d S )
NrT   rH   r   rU   r   rJ   z2 or 3 functions are expectedrL   r   )r   r'   r(   r/   r_   r  r<   r<   r=   test_0d_comparison
  s    
*
z TestPiecewise.test_0d_comparisonc                 C   s8   t d}t |dk}t||gddg}t|d d S )NrT   rL   rJ   )r6   r   r   r'   )rb   r   r   r   r<   r<   r=   test_0d_0d_condition
  s    
z"TestPiecewise.test_0d_0d_conditionc                 C   sR   t g dg dg}t||dk |dkgg d}t|t g dg dg d S )N)g      g      r  )r   r  r  r   rJ   r/  )r  r  r  )r   r   r   )r6   r   r   r(   r  r<   r<   r=   test_multidimensional_extrafunc
  s    
z-TestPiecewise.test_multidimensional_extrafuncc                 C   s^   G dd dt j}t d|}t||dk |dkgg d}tt|| t|g d d S )Nc                   @   s   e Zd ZdS )z/TestPiecewise.test_subclasses.<locals>.subclassNr   r<   r<   r<   r=   r   
  s   r   r   r   rH   )r  r   r   )r  r  r   r   r   )r6   r   r7   r   r   r'   r   )rb   r   r   r>  r<   r<   r=   r   
  s
    zTestPiecewise.test_subclassesN)rs   rt   ru   r2  rL  rM  rN  rA  rO  rP  rQ  r   r<   r<   r<   r=   rJ  g
  s   	rJ  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d Z	dd Z
dd Zdd Zejje dddd Zejdddggdgdd ZdS )TestBincountc                 C   s$   t t d}t|t d d S )NrH   )r6   bincountr7   r(   r`   r  r<   r<   r=   r2  
  s    zTestBincount.test_simplec                 C   s,   t t g d}t|t g d d S )N)rL   rU   rJ   rH   rL   )r   rJ   rL   r   rL   rL   )r6   rS  r   r(   r  r<   r<   r=   test_simple2
  s    zTestBincount.test_simple2c                 C   s2   t d}t g d}t ||}t|| d S )NrH   )皙?333333?r   r  )r6   r7   r   rS  r(   rb   r   r   r   r<   r<   r=   test_simple_weight
  s    
zTestBincount.test_simple_weightc                 C   s@   t g d}t g d}t ||}t|t g d d S )NrL   rJ   rH   rU   rJ   rU  rV  r   r  rU  )r   rU  r   r   r   r  r6   r   rS  r(   rW  r<   r<   r=   test_simple_weight2
  s    z TestBincount.test_simple_weight2c                 C   sV   t g d}t j|dd}t|t g d g }t j|dd}t|t g  d S )N)r   rL   r   rL   rL   rT   Z	minlength)rJ   rT   r   r   r[  r  r<   r<   r=   test_with_minlength
  s    z TestBincount.test_with_minlengthc                 C   sV   t g d}t j|dd}t|t g d t j|dd}t|t g d d S )N)r   rL   rL   rJ   rJ   rT   rT   rJ   r]  )rL   rJ   rJ   rJ   r   r[  r  r<   r<   r=   )test_with_minlength_smaller_than_maxvalue
  s
    z6TestBincount.test_with_minlength_smaller_than_maxvaluec                 C   sB   t g d}t g d}t ||d}t|t g d d S )NrY  rZ  rn   )r   rU  r   r   r   r  r   r   r[  rW  r<   r<   r=   test_with_minlength_and_weights
  s    z,TestBincount.test_with_minlength_and_weightsc                 C   s&   t jg td}t |}t|| d S r  )r6   r   r  rS  r(   r  r<   r<   r=   r  
  s    
zTestBincount.test_emptyc                 C   s4   t jg td}t j|dd}t|t jdtd d S )Nr   rU   r]  )r6   r   r  rS  r(   r?   r  r<   r<   r=   test_empty_with_minlength
  s    z&TestBincount.test_empty_with_minlengthc                    sl   t jg td ttd fdd ttd fdd t d ttd fdd ttd fd	d d S )
Nr   z"'str' object cannot be interpretedc                      s   t j ddS Nfoobarr]  r6   rS  r<   r  r<   r=   r    r  z<TestBincount.test_with_incorrect_minlength.<locals>.<lambda>zmust not be negativec                      s   t j ddS Nr[   r]  rd  r<   r  r<   r=   r    r  rU   c                      s   t j ddS rb  rd  r<   r  r<   r=   r    r  c                      s   t j ddS re  rd  r<   r  r<   r=   r    r  )r6   r   r  r/   r   r_   r7   r|   r<   r  r=   test_with_incorrect_minlength   s$    




z*TestBincount.test_with_incorrect_minlengthr  r  c                 C   s   t ttj}t ttj}tdD ]}tg d q,tt ttj| tt ttj| tdD ]}tg dg d qxtt ttj| tt ttj| d S )Nr   r   r   )	r  r  r6   r   Zintpr  ra   rS  r'   )rb   Zintp_refcountZdouble_refcountjr<   r<   r=   test_dtype_reference_leaks  s    z'TestBincount.test_dtype_reference_leaksvalsrJ   c                 C   sr   t |}tt t | W d    n1 s20    Y  tt t | W d    n1 sd0    Y  d S r5   )r6   asarrayr+   r_   rS  )rb   ri  Zvals_arrr<   r<   r=   test_error_not_1d!  s
    

(
zTestBincount.test_error_not_1dN)rs   rt   ru   r2  rT  rX  r\  r^  r_  r`  r  ra  rf  r   r  r  r1   rh  r  rk  r<   r<   r<   r=   rR  
  s   
rR  c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	dd dd dd dd gg dd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 )'
TestInterpc                 C   st   t ttdg g  t ttddgddg t ttdddgddgdd t ttdg g dd t ttddgddgdd d S )Nr   rL   rJ   r  h  )r+   r_   r   r|   r<   r<   r=   test_exceptions-  s
    zTestInterp.test_exceptionsc                 C   sB   t ddd}t ddd}t ddd}tt |||| d S )Nr   rL   rU   rg   )r6   r  r)   r   rb   r   r   x0r<   r<   r=   rf   4  s    zTestInterp.test_basicc           
      C   s  t ddD ]}tj|tjd}tj|tjd}tjdd|d |gtjd}|d d d }t|||}t|||}tjg dtd}|d d d }	t|| t||	 t|||dd}t|||dd}tjg dtd}|d d d }	t|| t||	 t|||d	d
}t|||d	d
}tjg dtd}|d d d }	t|| t||	 t|||dd	d}t|||dd	d}tjg dtd}|d d d }	t|| t||	 q
d S )NrL   r   r   r[   r   r   left)r   rL   rL   rL   rJ   right)rL   rL   rL   rJ   )rr  rt  )r   rL   rL   rJ   )	ra   r6   r7   r  r`   r   r   rN  r'   )
rb   sizexpZypZincptsZdecptsZincresZdecresZinctgtZdectgtr<   r<   r=   test_right_left_behavior:  s:    






z#TestInterp.test_right_left_behaviorc                 C   s   t ddd}t ddd}d}tt |||| d}tt |||| t d}tt |||| t d}tt |||| t j}tt |||| d S )Nr   rL   rU   rV  )r6   r  r)   r   r   r   r"  ro  r<   r<   r=   test_scalar_interpolation_point`  s    

z*TestInterp.test_scalar_interpolation_pointc                 C   st   g d}g d}ddt jdg}tt |||ddt jt jdg ddt jdg}tt |||ddt jt jdg d S )NrL   rJ   r  rT   rH   r`  rL   rJ   rH   )r6   r  r)   r   r"  )rb   r   rv  fpr<   r<   r=    test_non_finite_behavior_exact_xn  s    "z+TestInterp.test_non_finite_behavior_exact_xc                 C   s
   t | S r5   r6   r   r  r<   r<   r=   r  w  r  zTestInterp.<lambda>c                 C   s
   t | dS r(  rF   r  r<   r<   r=   r  x  r  c                 C   s
   t d| S r(  r}  r  r<   r<   r=   r  y  r  c                 C   s   t | t| dS )NrR   )rF   r6   multiplyr  r<   r<   r=   r  z  r  )rC   zcomplex-realzcomplex-imagzcomplex-both)paramsZidsc                 C   s   |j S )z( scale function used by the below tests )param)rb   requestr<   r<   r=   scv  s    zTestInterp.scc                 C   s   t tdtjdg|ddg|tj t tddtjg|ddg|tj t tdddg|tjdg|tj t tdddg|dtjg|tj dS )z test that nans are propagated r   rL   r   r   N)r'   r6   r   r"  rb   r  r<   r<   r=   test_non_finite_any_nan  s    (((z"TestInterp.test_non_finite_any_nanc                 C   s   t tdtj tj
 g|ddg|tj t tdddg|tj tj
 g|tj t tdddg|tj
 tj g|tj t tdtj tj
 g|ddg|d dS )z2 Test that interp between opposite infs gives nan r   r   r   rL   Nr'   r6   r   r  r"  r  r<   r<   r=   test_non_finite_inf  s    ...zTestInterp.test_non_finite_infc                 C   st  t tdtj dg|tj dg|tj t tdtj dg|tj
 dg|tj t tdtj dg|dtj g|tj t tdtj dg|dtj
 g|tj t tddtj
 g|tj dg|tj t tddtj
 g|tj
 dg|tj t tddtj
 g|dtj g|tj t tddtj
 g|dtj
 g|tj dS )z@ Test that interp where both axes have a bound at inf gives nan r   rL   r   r   Nr  r  r<   r<   r=   test_non_finite_half_inf_xf  s    .......z&TestInterp.test_non_finite_half_inf_xfc                 C   s   t tdtj tj g|ddg|d t tdtj dg|ddg|d t tddtj
 g|ddg|d t tdtj
 tj
 g|ddg|d dS )z1 Test interp where the x axis has a bound at inf r   r   r   rL   Nr'   r6   r   r  r  r<   r<   r=   test_non_finite_half_inf_x  s    ,((z%TestInterp.test_non_finite_half_inf_xc                 C   s  t tdddg|dtj g|tj  t tdddg|dtj
 g|tj
  t tdddg|tj dg|tj  t tdddg|tj
 dg|tj
  t tdddg|tj tj g|tj  t tdddg|tj
 tj
 g|tj
  dS )z1 Test interp where the f axis has a bound at inf r   r   rL   r   Nr  r  r<   r<   r=   test_non_finite_half_inf_f  s    ,,,,0z%TestInterp.test_non_finite_half_inf_fc           	      C   s  t ddd}t ddddt ddd d  }d}|d| d  }tt |||| d}d}tt j||||d| d	}d}tt j||||d
| g d}g d}ddt jdg}ddt jd t jdg}tt |||| g d}g d}g d}g d}tt j|||dd| d S )Nr   rL   rU   r  rV  r[          @      @rq  r   rs  ry  r`         @      ?rH   y              ?iLiViG   r  rT  r   im     iBi^  i)      @      ?y      $@       @      @      @y      @      @)y      @      ?r  y     !@      ?y      @      ?r  y      
@      
@y      @      @y      @      @rm  r  )r6   r  r)   r   r  )	rb   r   r   rp  Zy0rr  rt  rv  rz  r<   r<   r=   test_complex_interp  s*    $zTestInterp.test_complex_interpc                 C   s   t ddd}t ddd}t d}tt |||| t g d}t g d}t t d||}t|d tt|t j t jt d||dd	}t|d
 tt|t j d S )Nr   rL   rU   rV  r  )rL   r[   rL   r  rH   r  r   )	r6   r  r   r)   r   r'   r&   rC  r   )rb   r   r   rp  rv  rz  r   r<   r<   r=   )test_zero_dimensional_interpolation_point  s    


z4TestInterp.test_zero_dimensional_interpolation_pointc                 C   s2   t ddd}t |}tt t j||d d S )Nr   r   g-C6?r   )r6   r7   sinr)   r   r  )rb   rv  rz  r<   r<   r=   test_if_len_x_is_small  s    
z!TestInterp.test_if_len_x_is_smallc                 C   s   g d}g d}g d}g d}t tj|||dd| tj|ddd	d
}tj|ddd	d
}t tj|||dd| d S )Nr  r  )rU   r   rT   rH   )g      @r        !@g      @r   g      
@      @g      @rm  r  r   r   rJ   r[   r  )r)   r6   r   r   rq   )rb   r   rv  rz  r   r<   r<   r=   r    s    zTestInterp.test_periodN)rs   rt   ru   rn  rf   rw  rx  r{  r   Zfixturer  r  r  r  r  r  r  r  r  r  r<   r<   r<   r=   rl  +  s.   &
		rl  c                   @   sp  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	
dejd dd Zdd ejd D ejejfejejfejejfejejfedejfg Zej	
ddgejdfejdfgej	
ddgeej	
g dg ddd Zejd ejd  d Zej	
dedd Zej	
dedd  Zej	
ded!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Z ej	
d/ejd0fe!ejd1d2d3fgd4d5 Z"d6d7 Z#d8d9 Z$d:d; Z%d<d= Z&d>d? Z'd@dA Z(dBdC Z)ej	
dDdEdFdEggej	j
dGg dHdIdJdK Z*dLdM Z+ej	
dNg dOdPdQ Z,dRdS Z-dTdU Z.ej	
ddVdWgej	
dXg dYdZd[ Z/d\S )]TestPercentilec                 C   s   t dd }tt |dd tt |dd tt |dd t j|d	< tt |dt j tt j|dd
dt j tt j|dddt j tt j|ddt |dt j d S )Nrn   r   r   r   r,  r  rg   r   rL   nearestmethodinverted_cdfr  r   )r6   r7   r'   
percentiler"  r  rF  r<   r<   r=   rf     s    

zTestPercentile.test_basicc                 C   s   dd t dD }t|td}t|td tt|t t|td}t|tdd tt|t t|td}t|tdd	 tt|t t|tdg}t|ttdd	g tt|tj d S )
Nc                 S   s   g | ]}t |d qS rJ   r   rE  r<   r<   r=   r     r  z0TestPercentile.test_fraction.<locals>.<listcomp>rn   r   r,  rp   rJ   rg   rH   )ra   r6   r  r   r'   r   r   r   )rb   r   rR  r<   r<   r=   test_fraction  s    zTestPercentile.test_fractionc                 C   sR   t d}t |dd d d t |dd d dd t d}t |dd |dd d S )NrU   Flinearr  )r6   r`   r  )rb   r$  or<   r<   r=   test_api  s
    

zTestPercentile.test_apic                 C   sj   t jg ddd}ttt j|d t jg ddd}ttt j|d t jg ddd}ttt j|d d S N)y      ?      @y @      ?y?ffffff@Gr   r   Dr   )r6   r   r+   r   r  rb   Zarr_cr<   r<   r=   r    s    zTestPercentile.test_complexc                 C   sF   t g dg dg dg dg dg}tt j|dddg d d S )Nr   )rH   rH   rT   rg   r   rw   )r6   r   r(   r  rF  r<   r<   r=   test_2D   s    
zTestPercentile.test_2Dr   r  c                 C   sP   t jdt jdddg|d}t j|ddd}t j|t j t j|j|j d S )Nr]       A@      D@      I@r   r  r  )r6   rj  r"  r  testingr'   r   )rb   r   r   r  r<   r<   r=   test_linear_nan_1D(  s    z!TestPercentile.test_linear_nan_1Dc                 C   s   g | ]}|t jfqS r<   r|  )r   Zint_typer<   r<   r=   r   3  s   zTestPercentile.<listcomp>r  r  functionquantiler  r  input_dtypeexpected_dtype)r  weightedr  )
)r  FrL  )r  TrL  )averaged_inverted_cdfF     ;@)closest_observationFrL  )interpolated_inverted_cdfFrL  )hazenFr  )weibullF   )r  Fr  )median_unbiasedFri  )normal_unbiasedFg      ;@c                 C   s   t |}t  dkr$t |t j}t jg d|d}|rDt |nd }	|t ju rn|t ju rd|d}t j	j
}
nt j	j}
|||||	d}|
||| |dv r|dkrt j	t |jt j qt j	t |jt | nt j	t |jt | d S )Nlegacy)r]  g      4@r  r  r  r   z0.4r  )r  r  r  )r6   r   Z_get_promotion_stateZpromote_typesr   rj  r  r  r  r  r)   Zassert_array_almost_equal_nulpr   r'   )rb   r  r  r  r  r  r  r  r   r   Ztest_functionr   r<   r<   r=   test_linear_interpolation;  s*    



z(TestPercentile.test_linear_interpolationc                 C   sD   t tjtjd|ddddd t tjtjd|ddddd d S )	Nr   r   rg   lowerr  rH   higherrU   r'   r6   r  r7   rb   r   r<   r<   r=   test_lower_highers  s    z TestPercentile.test_lower_higherc                 C   s   t tjtjd|ddddd t tjtjd|dd d	ddd
 t tjtjd|ddddd t tjtjd|dd	ddd
 d S )Nr   r   3   midpointr  r  r
  rL   rg   rU   r         @r  r  r<   r<   r=   test_midpointz  s(    zTestPercentile.test_midpointc                 C   sD   t tjtjd|ddddd t tjtjd|ddddd d S )	Nr   r   r  r  r  rU   1   rH   r  r  r<   r<   r=   test_nearest  s    zTestPercentile.test_nearestc                 C   sL   t jd}t |d}t j||  t |d}t j||  d S )NrU   r,  r   )r6   r  r3   r  r  r'   r  r  )rb   r   r   r<   r<   r=   'test_linear_interpolation_extrapolation  s
    z6TestPercentile.test_linear_interpolation_extrapolationc                 C   s,   t dd }tt |g dg d d S )Nrn   r   )r   r,  rg   )r   r  r   )r6   r7   r'   r  rF  r<   r<   r=   test_sequence  s    zTestPercentile.test_sequencec                 C   s  t ddd}tt |dg d g dg dg dg}tt j|dd	d
| g dg dg dg}tt j|ddd
t |j t ddddd}tt |djd tt |djd tt j|dd	d
jd tt j|ddd
jd tt j|ddd
jd tt j|ddd
jd tt j|ddd
jd tt j|dddjd tt j|dddjd tt j|dd	ddjd tt j|ddddjd tt j|ddddjd tt j|ddddjd tt j|ddddjd d S )Nr   rT   rH   )r  rg   r,  )g      @r  r  )rJ   rT   rH   rU   r5  )rn   r
  r   r   r   rw   )      ?r  rT   )r   r  rp   )r  r   r   rL   rm  rU   ro   r  rg   r  )r  rg   r  rT   )rJ   rH   rU   ro   )rJ   rT   rU   ro   rJ   )rJ   rT   rH   ro   )rT   rT   rU   ro   r  r  rx   r  )r6   r7   rq   r'   r  r   r   rA   )rb   r   r0r7  r<   r<   r=   r    sf    

zTestPercentile.test_axisc                 C   s  t ddd}tt |dd tt t |d t g d}tt j|ddd| tt j|dddj|j t g d	}t	t j|dd
d| tt j|dd
dj|j t 
d
}tt j|d|dd t|d t 
d}tt j|dd|d| t|| t 
d}tt j|dd
|d| t|| t ddd}tt j|dddd tt t |d t g d}t j|dddd}t|| t|j|j t g d}t j|ddd
d}t	|| t|j|j t j
d|jd}t j|dd|d}t|d t|d t j
d|jd}t j|ddd|d}t|| t|| t j
d|jd}t j|ddd
|d}t|| t|| d S )Nr   rT   rH   rg   r  r   r   r   r   r   rw   r  r  r   rL   r  rx   r  r  r  r   )r  rx   )r   r   r   r<   r   r  r  rU   r  rx   r  )r6   r7   rq   r'   r  r&   isscalarr   rA   r)   emptyr   )rb   r   r  r7  r  Zc0c1r   r<   r<   r=   test_scalar_q  sR    












zTestPercentile.test_scalar_qc                 C   s   t ttjddgddd t ttjdgd t ttjdgd t ttjdgttddg  t ttjdgttdd	g  d S )
NrL   rJ   8   rc  r  e   r[   rg   r  )r+   r_   r6   r  r  ra   r|   r<   r<   r=   test_exception  s     zTestPercentile.test_exceptionc                 C   s   t tg ddd d S )Nr   r   rL   )r'   r6   r  r|   r<   r<   r=   test_percentile_list  s    z#TestPercentile.test_percentile_listzpercentile, with_weightsFr  r  Tc                 C   sz  |rt nt}tg d}tjd|d}d}|r:t|nd }|||||d}||u sZJ t||||d| tg dg dg}tjd|d}|rt|nd }|||d||d	}||u sJ t||||dd
| tjd|d}|||d||d	 t||||dd
| tddd}|r>tg dg dg}	ntg dg dg}	tj	d|d}
|rrt|nd }t||dd|
|d	|	 t|
|	 tg dg dg}t	d}
ttj
|dd|
d| t|
| tg dg dg}	tj	d|jd}
tj
|ddd|
d}t||	 t|
|	 tg dg dg}tj	d|jd}
tj
|ddd|
d}t|| t|
| d S )Nr   r  r   )r  r   r   r   r  r   )rx   r  r   r   rT   rJ   rL   r   rT   rH   r   rL   rJ   rT   r5  )r   r   r   r   r  )rJ   rH   r  )r  r   r  r  r  r  r  r  )r   rH   rn   )rL   rU   r
  )r  rN  r6   r   r?   r  r'   r7   rq   r  r  r   )rb   r  Zwith_weightsZ	out_dtyper   r   rR  r   r>  r  r  r7  r   r<   r<   r=   test_percentile_out  sV    






z"TestPercentile.test_percentile_outc                 C   s  t ddddd}tt j|dddjd tt j|dddjd	 tt j|dddjd
 tt j|dddjd tt j|dddjd tt j|dddjd
 tt j|dddjd	 tt j|dddjd tt j|ddddjd
 tt j|ddddjd
 tt t j|ddgddjd tt t j|ddgddjd tt t j|ddgddjd tt t j|ddgddjd d S )Nrk  r   rL   rJ   rg   r   rw   )rL   rJ   rL   )r   rJ   rL   )r   rL   rL   rT   )r   rL   rJ   r[   rR   rX   r<  r  r  r   )rJ   rL   rJ   rL   )rJ   r   rJ   rL   )rJ   r   rL   rL   )rJ   r   rL   rJ   )r6   r7   rq   r(   r  rA   r   rb   r$  r<   r<   r=   test_percentile_empty_dim2  s>    z(TestPercentile.test_percentile_empty_dimc                 C   sh   t g d}t j|dgdd t|t g d t g d}t |dg t|t g d d S )NrJ   rT   rH   rL   rg   Foverwrite_inputr6   r   r  r'   rl   r<   r<   r=   test_percentile_no_overwriteN  s    z+TestPercentile.test_percentile_no_overwritec                 C   s   t jdddd}t jt d|dd t|t jdddd t jdddd }t jt d|dd t|t jdddd  d S )Nr         Y@rU   )numr  r  )r6   r  r  r7   r(   r  )rb   rR  r<   r<   r=   test_no_p_overwriteW  s    z"TestPercentile.test_no_p_overwritec                 C   s^   t g d}t j|dgdd}t|t dg t jg ddgdd}t|t dg d S )Nr  rg   Tr  r  r  r~   r<   r<   r=   test_percentile_overwrite_  s
    z(TestPercentile.test_percentile_overwritec              
   C   s  t jjdd}t |gd }tt j|dddt |d t |dd}tt j|dd	dt |d |dd
 }tt j|dddt |d |dd
 }tt j|ddgddt j|ddgd d tt j|ddgddt j|ddgdd t 	d
d}t j|  tt j|dddd t |d d d d d d df  d tt j|ddgddd d d
f t |d d d d d
d d f  ddg tt j|dddd t |d d d d dd d f  d tt j|dddd t |dd d d d d d f  d tt j|dddd t |dd
d d d d f  d tt j|dddd t |dd d d d d
f  d tt j|dddd t |dd d dd d f  d d S )NG      ru  r   rc  r\   rw   r[   r   rk   rL   ri   r  r  rK   r     rT   rU   rp   r   Z   r   rL   rT   rT   rL   r<  rJ   rT   rL   rJ   r  rJ   rL   rL   rR   rL   rT   rO   )r6   r  normaldstackr'   r  moveaxisr   r   r7   rq   shuffleravelflattenrb   r  r   r$  r<   r<   r=   test_extended_axisg  sJ    & *&&"""z!TestPercentile.test_extended_axisc                 C   s   t d}ttt j|ddd ttt j|ddd ttt j|ddd ttt j|ddd ttt j|ddd ttt j|d	dd ttt j|d
dd d S )Nr  rT  r  )rx   r  r   rT  rH   r   rH   rQ   )r[   r[   )rT   r[   )r6   r`   r+   r%   r  r_   r  r<   r<   r=   test_extended_axis_invalid  s    
z)TestPercentile.test_extended_axis_invalidc                 C   s   t d}tt j|dd ddjd tt j|ddddjd tt j|ddddjd	 tt j|dd
ddjd tt j|ddddjd tt j|ddddjd tt j|ddgdddjd tt j|ddgdddjd d S )Nr  rp   Tr   r   r\   rL   rL   rp   r   rz   rL   rU   rp   rL   r  rT   rL   rp   r   r  )r   r  rL   rL   rp   rL   rL   )rJ   rL   rL   rp   rL   )rJ   rL   rU   rp   rL   )r6   r`   r'   r  rA   r  r<   r<   r=   test_keepdims  s:    
zTestPercentile.test_keepdimsr  rp   rL   rx   NrL   r  r\   )rX   r[   argnamesZ	argvaluesc                    s   t d|d u rdj }n*t|j t fddtjD }t || }t |}t j||d|d}||u sJ t	|j| d S )Nr  r  c                 3   s$   | ]}| v rd nj | V  qdS rL   NrA   rE  Z	axis_normr$  r<   r=   r    s   z3TestPercentile.test_keepdims_out.<locals>.<genexpr>Trx   r   r  )
r6   r`   r   r4   r  ra   rA   r  r  r'   )rb   r  rx   	shape_outr  r  r<   r  r=   test_keepdims_out  s    

z TestPercentile.test_keepdims_outc                 C   s   t d}t d}tt j|dd|d| tt j|ddd|d| t d}tt j|dd|d| tt j|ddd|d| t d	}tt j|d
|d| tt j|d
d|d| d S )NrH   r>  r   r  r  r  r  rL   r<   rJ   )r6   r?   r`   r'   r  rb   r  r$  r<   r<   r=   test_out  s    



zTestPercentile.test_outzmethod, weighted))r  F)r  F)r  F)r  Tc                 C   s   |rt d|d}nd|i}tjdd tddt t d}t d}t j|d	< tt j	|d
d
fd|i|| t d}tt j	|ddfd|i|| t d}tt j	|dfd|i|| W d    n1 s0    Y  d S )Nr>  r   r  r  Tr1  r3  r4  r  r  r   r  r  rL   r<   )
r6   r`   r6  r7  r8  r  r?   r"  r'   r  )rb   r  r  kwargsr  r$  r<   r<   r=   test_out_nan  s    


 
 
zTestPercentile.test_out_nanc                 C   s:  t jdtd}t j|d< tt |dt j tt j|dddt j tt j|ddgddt t jgd  t jdtdddd	}t j|d
< t j|d< tt |dt j tt |djd t t jdtdddd	dd}t j|d< t j|d< tt |dd| t t jdtdddd	ddgd}t j|d d ddf< t j|d d ddf< tt |ddgd| t t jdtdddd	dd}t j|d< t j|d< tt |dd| t t jdtdddd	ddgd}t j|d d ddf< t j|d d ddf< tt |ddgd| t t jdtdddd	dd}t j|d< t j|d< tt |dd| t t jdtdddd	ddgd}t j|d d df< t j|d d df< tt |ddgd| t jt jdtdddd	ddgddd}t j|d d df< t j|d d df< tt j|ddgddd| d S )Nr;  r   rJ   rV  r   rw   333333?rT   rH   r   rL   rL   rJ   r  rj   rL   r  rP   r  r  )	r6   r7   rN  r"  r'   r  r   rq   r   r~   r<   r<   r=   test_nan_behavior  sl    


"

"




z TestPercentile.test_nan_behaviorc                 C   s   t jtdd" tg dtj W d    n1 s60    Y  t jtdd$ tg dtjg W d    n1 sx0    Y  tddd}tj|d< t jtdd  tg d| W d    n1 s0    Y  d S )NzPercentiles must be inr   )rL   rJ   rT   r   r   g     X@rf  r   )r   r   r_   r6   r  r"  r  )rb   r  r<   r<   r=   
test_nan_q"  s    02
zTestPercentile.test_nan_qzm8[D]zM8[s]posr   r  r   c                 C   s   t jdd|d}d||< t |d}|j|ks2J t |s@J t |ddg}|j|ks^J t | spJ t jdd|ddd	}d||d
f< t j|ddd}tt |g d d S Nr   r;  r   ZNaTrc  r  H   r[   rT   rL   rw   r  )r6   r7   r  r   isnatr   rq   r(   rb   r   r  rc   r  r<   r<   r=   test_nat_basic-  s    zTestPercentile.test_nat_basicN)0rs   rt   ru   rf   r  r  r  r  r   r  r  r6   	typecodesr  r  r   r   r  r   ZH_F_TYPE_CODESr  r  r  Z
TYPE_CODESr  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    s   





&



	$0
3	 

=r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r  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d Z	e
jdejd dd Ze
jdedd Ze
jdedd Zejeejejdddejddddddd d!d" Zd#d$ Ze
jd%dd&ge
jdee
jd'g d(d)d* Ze
jd%dd&ge
jdee
jd'g d(d+d, Ze
jdee
jd'g d(d-d. Ze
jdee
jd'g d/d0d1 Z e
jded2d3 Z!d4d5 Z"e
jde#e$ee$e d6d7 Z%d8d9 Z&d:d; Z'd<S )=TestQuantilec                 C   s   ||k| S r5   r<   )rb   r   r   alphar<   r<   r=   r  N  s    zTestQuantile.Vc                 C   s*   g d}t |d}t jj|ddd d S )N)r   rU  r  g?g
ףp=
?rL   )Zmaxulp)r6   r  r  Zassert_array_max_ulp)rb   r   rc   r<   r<   r=   test_max_ulpR  s    zTestQuantile.test_max_ulpc                 C   sH   t dd }tt |dd tt |dd tt |dd d S )Nrn   r   r   r   rL   r  r   )r6   r7   r'   r  rF  r<   r<   r=   rf   Z  s    zTestQuantile.test_basicc                 C   sl   t dg}t dd}t||d  tt||j t g d}t ||}t|| t|j|j d S )NTFr   )FTT)r6   r   r  r'   r   r   r(   )rb   rc   Ztf_quantZ	quant_resr<   r<   r=   test_correct_quantile_value`  s    
z(TestQuantile.test_correct_quantile_valuec                 C   s^  dd t dD }t|d}t|d tt|t t|d}t|tdd tt|t t|d}t|d	 tt|tj t|tdd}t|tdd
 tt|t t|tddg}t|ttdd
g tt|tj t|tddgg}t|ttdd
gg tt|tj t	d}tt|tddtdd d S )Nc                 S   s   g | ]}t |d qS r  r   rE  r<   r<   r=   r   l  r  z.TestQuantile.test_fraction.<locals>.<listcomp>rn   r   rL   rp   rJ   r   r   rH   )
ra   r6   r  r'   r   r   r   r   r   r7   )rb   r   r  r<   r<   r=   r  j  s*    


zTestQuantile.test_fractionc                 C   sj   t jg ddd}ttt j|d t jg ddd}ttt j|d t jg ddd}ttt j|d d S r  )r6   r   r+   r   r  r  r<   r<   r=   r    s    zTestQuantile.test_complexc                 C   sj   t g d}| }t jt d|dd t|| | }| }t jt d|dd t|| d S )N)r   r  r  r   r   r  r  r  )r6   r   r   r  r7   r(   r  )rb   p0rR  r<   r<   r=   r    s    
z TestQuantile.test_no_p_overwriter   r  c                 C   s2   t jt jddg|ddgdd}|j|ks.J d S )NrL   rJ   r   r   r  r  )r6   r  r   r   )rb   r   r  r<   r<   r=   test_quantile_preserve_int_type  s    z,TestQuantile.test_quantile_preserve_int_typer  c                 C   s4   g d}t j|ddg|d}t|t ddg d S )N)r   r   r   r   rL   )r  r  r   r   )r6   r  r'   r   )rb   r  r   r  r<   r<   r=   test_q_zero_one  s    zTestQuantile.test_q_zero_onec                 C   sd   t ddd}t jt g dd ||d}tt || t jg d||d}tt || d S )Nr   rL   r  )r   rL   rL   rJ   rJ   rT   rT   rH   rU   rU   rL   rL   r
  r
  r
  rn   rn   rp   r  r  )r   r   r   r   )r6   r  r  r   r'   r  )rb   r  r*  r  r<   r<   r=   test_quantile_monotonic  s    z$TestQuantile.test_quantile_monotonicrT   r  )	min_value	max_valueFu <7u <7~)allow_infinity	allow_nanr.  r/  )r   rA   elements)r   c                 C   s.   t ddd}t ||}tt || d S )Nr   rL   g{Gz?)r6   r7   r  r'   r  )rb   r   r*  r  r<   r<   r=   test_quantile_monotonic_hypo  s    z)TestQuantile.test_quantile_monotonic_hypoc                 C   sV   t g dg dg}t j|d d< t |d}t |s>J tt |dt j d S )N)rU  r   r   )r   r   r   r   rL   r   )r6   r   r"  r  r  r'   )rb   rc   r   r<   r<   r=   test_quantile_scalar_nan  s
    z%TestQuantile.test_quantile_scalar_nanr   Tr'  )rU  r   ?c           	   	   C   s  |r|t vrtd tjd}d}||}|rD|jdd|dnd }tj||||d}|dv rtt	| 
|||d	| ksJ ntt|| || kr|sttj| 
||||d
ddd n8ttj| 
||||d
dd| t|d| g d d S )N Weights not supported by method.  f   r   r   lowhighru  r  )r  r  r   g+=)ZatolrL   )methods_supporting_weightsr   skipr6   r  default_rngintegersr  r  r   r  r  r,   r   r[  )	rb   r   r  r'  rngr:   r   r   r   r<   r<   r=   %test_quantile_identification_equation  s     

(z2TestQuantile.test_quantile_identification_equationc           
      C   s  |r|t vrtd tjd}d}||}|rD|jdd|dnd }tj||||d}d}	ttj|	| |||d|	|  ttj|	| |||d|	|  |rd S tj| d	| |d
 }|dkr.|| t	|| kst
|| t	|| d	 krt|tj||dd
 nt|tj||dd
 nl|dkr|| t	|| krft|tj||dd
 nVt
|| t	|| d	 krt|tj||d	|  dd
 nt|tj||dd
 n|dkrt|tj||d	|  |d
 n|dkr@|| t	|| kr(t|tj||d	|  |d
 nt|tj|||d
 nZ|dkrbt|tj||dd
 n8|dkrt|tj||dd
 nt|tj|||d
 d S )Nr8  r9  r:  r   r   r;  r  g      +@rL   r  r  r  r  r  r  r  )r>  r   r?  r6   r  r@  rA  r  r,   r  round)
rb   r   r  r'  rB  r:   r   r   r  r   r<   r<   r=   'test_quantile_add_and_multiply_constant  sV    



 
 
 

z4TestQuantile.test_quantile_add_and_multiply_constantc           	      C   s~   t jd}d}||}t j|||d}t |}t j||||d}t|| dt | }t j||||d}t|| d S )Nr9  r:  r  r  g     @ @)r6   r  r@  r  r  r,   )	rb   r  r'  rB  r:   r   r  r   qwr<   r<   r=   test_quantile_constant_weights2  s    


z+TestQuantile.test_quantile_constant_weights)r   rU  r   r7  rL   c           	      C   sf   t jd}d}||}|jdd|t jd}t j||||d}t jt ||||d}t|| d S )Nr9  r:  r   r   )r<  r=  ru  r   r  r  )r6   r  r@  rA  rn  r  r=  r,   )	rb   r  r'  rB  r:   r   r   rF  r  r<   r<   r=   "test_quantile_with_integer_weightsF  s    
z/TestQuantile.test_quantile_with_integer_weightsc           
   
   C   s  t jd}|d}t |d}d}t j||||dd}t jdd}td	D ]:}td
D ],}	t j||d d |	f |||d|||	f< q^qRt|| g d}t j||||dd}t jdd}td	D ]@}td
D ]2}	t j||d d |	f |||d|d d ||	f< qqt|| ddgddgddgg}t j||||dd}|d}t|| t |d}d}t j||||dd}t jdd}td	D ]L}td
D ]<}	t j||d d |	f ||||d d |	f d|||	f< qqt|| d S )Nr9  )rJ   r   rT   r   r   rL   )r   r  rx   r  r  rJ   rT   r  )r   rU  r  r  r  rL   )ro   rJ   rT   r   rU  r  r  r  )rT   rJ   rJ   rT   )	r6   r  r@  r  r  r?   ra   r,   rq   )
rb   r  rB  r   r   r'  r  Zq_resr   rg  r<   r<   r=   #test_quantile_with_weights_and_axisW  sF    




$z0TestQuantile.test_quantile_with_weights_and_axisc                 C   sT   ddg}ddg}t jtdd" tj|d|dd W d    n1 sF0    Y  d S )	NrL   rJ   r  zWeights must be non-negativer   r   r  r  r   r   r_   r6   r  )rb   r   r   r<   r<   r=   -test_quantile_weights_raises_negative_weights  s    z:TestQuantile.test_quantile_weights_raises_negative_weightsc                 C   sX   ddg}ddg}d}t jt|d" tj|d||d W d    n1 sJ0    Y  d S )NrL   rJ   r   z+Only method 'inverted_cdf' supports weightsr   r  rJ  )rb   r  r   r   r  r<   r<   r=   0test_quantile_weights_raises_unsupported_methods  s
    z=TestQuantile.test_quantile_weights_raises_unsupported_methodsc                 C   sn   t ddt ddg}tj|dgdd}t|tt dd tj|t ddgdd}t|tt dd d S )Nr   rL   r   r  r  rJ   rL  )r   r6   r  r'   r   )rb   r   r  r<   r<   r=   test_weibull_fraction  s
    z"TestQuantile.test_weibull_fractionc                 C   s   d}d}g d}t dtj|dd ||d t dtj|dd ||d t dtj|dd	 ||d t dtj|dd
 ||d t dtj|dd ||d t dtj|dd ||d t dtj|dd ||d t d	tj|||d d S )Nr  r   )
rL   rJ   rT   rH   rU   ro   rp   rn   r
  r   rJ   r   rT   r  rH   rU   ro   rp   rn   r
  )r'   r6   r  )rb   r  r  r   r<   r<   r=   test_closest_observation  s    z%TestQuantile.test_closest_observationN)(rs   rt   ru   r  r(  rf   r)  r  r  r  r   r  r  r6   r%  r+  quantile_methodsr,  r-  
hypothesisgivenr   r   strA  floatsr5  r6  rC  rE  r>  rG  rH  rI  rK  sortedsetrL  rM  rN  r<   r<   r<   r=   r&  K  s^   
	



"@
-
r&  c                
   @   s   e Zd Zejejdddddejdddddejdddddejdddddddd	 Zejejdddddejdddddejdddddd
dd Zejejdddddejdddddejdddddd
dd Z	dd Z
dS )TestLerpFr   rL   )r3  r2  r.  r/  r0  r1  )t0t1rc   r   c                 C   sh   t |||}t |||}||ks,||kr:||ksdJ n*||k ||k krX||ksdJ n||ksdJ d S r5   rn  _lerp)rb   rW  rX  rc   r   Zl0l1r<   r<   r=   +test_linear_interpolation_formula_monotonic  s    	z4TestLerp.test_linear_interpolation_formula_monotonic)trc   r   c                 C   sV   ||kr.|t |||  kr&|ksRn J n$|t |||  krL|ksRn J d S r5   rY  )rb   r]  rc   r   r<   r<   r=   )test_linear_interpolation_formula_bounded  s    &z2TestLerp.test_linear_interpolation_formula_boundedc                 C   s6   t ||dd|  }t ||d| }t|| d S r\  )rn  rZ  r,   )rb   r]  rc   r   rr  rt  r<   r<   r=   +test_linear_interpolation_formula_symmetric  s    z4TestLerp.test_linear_interpolation_formula_symmetricc                 C   s8   t d}t d}t d}t|||dks4J d S )NrJ   rU   rU  g@)r6   r   rn  rZ  )rb   rc   r   r]  r<   r<   r=   +test_linear_interpolation_formula_0d_inputs  s    


z4TestLerp.test_linear_interpolation_formula_0d_inputsN)rs   rt   ru   rP  rQ  rR  rS  r\  r^  r_  r`  r<   r<   r<   r=   rV    sJ   



rV  c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	
dg ddejdgejdfdd Zdd Zdd Zdd Zej	jedddd Zdd Zdd Zd d! Zd"d# Zej	j
d$g d%d&d'd( Zej	
d)d*gej	
d+g d,d-d. Zd/S )0
TestMedianc                 C   s>  t d}t d}t ddd}tt |d tt |d tt |d tt j|ddg d	 tt j|dddd
g tt j|d dd t g d}t|d |d  d t | t g d}t|d t | t g d}t|d t | tt |jd t j	|d< tt |jd d S )NrL   rJ   ro   rT   r   r  r   rw   r  r  r  rH   )6-¦?0?}r?g4?r   )rd  rc  re  )rc  re  rd  r[   )
r6   r   r7   rq   r'   medianr,   r)   r   r"  )rb   a0a1ru  rc   r<   r<   r=   rf     s$    

 
zTestMedian.test_basicc                 C   s   t ddgddgddgddgg}|t jjdd	d
dfD ]B}| }t j|d d t|jD ]}t j||d q\t|| q8t	t j|ddddg t	t j|j
ddddg t	t |d t	t j|d dd t	t |j
d d S )NrJ   rT   r   rL   ro   rp   rH   rU   r,  r   r  rw   r  )r6   r   r  randintr   rf  ra   r   r(   r,   r   )rb   a3rc   origaxr<   r<   r=   test_axis_keyword  s     
zTestMedian.test_axis_keywordc                 C   s  t ddgddgddgddgg}t d}t d}t ddd}tt j| d	d
d tt j| d	d
d tt j| d	d
d tt j| d	ddg d tt j| d	ddddg tt j| d	d dd tt j| d	ddddg tt j|j d	ddddg t jdt jdd}t j	
|  tt j|d dt j| d d	d tt j|ddt j| dd	d tt j|ddt j| dd	d tt j|ddt j| dd	d d S )NrJ   rT   r   rL   ro   rp   rH   rU   Tr  r   r  )r  rx   rb  r  r   rS   rw   )rx   r  )r6   r   r7   rq   r,   rf  r   r   r   r  r  r  )rb   rj  rg  rh  ru  Za4r<   r<   r=   test_overwrite_keyword  sP    


z!TestMedian.test_overwrite_keywordc                 C   sF   g d}t t|d |g}t t|d ttj|dd| d S )Nr   rJ   r   rw   )r)   r6   rf  r,   )rb   r   r  r<   r<   r=   r  )  s
    zTestMedian.test_array_likec                 C   s2   G dd dt j}|g d}tt |d d S )Nc                   @   s    e Zd ZdddZdddZdS )z,TestMedian.test_subclass.<locals>.MySubClassNc                 S   s   t || }||_|S r5   )r6   rj  r   info)clsZinput_arrayro  objr<   r<   r=   __new__4  s    z4TestMedian.test_subclass.<locals>.MySubClass.__new__c                 S   s   dS )Nr<   )rb   rx   r   r  r<   r<   r=   r   9  s    z1TestMedian.test_subclass.<locals>.MySubClass.mean)N)NNN)rs   rt   ru   rr  r   r<   r<   r<   r=   
MySubClass2  s   
rt  r   rs  )r6   r   r'   rf  )rb   rt  rc   r<   r<   r=   rE  0  s    
zTestMedian.test_subclassr   r   r   r   r   c                 C   s:   G dd dt j}t t ||}t||s6J dS )z6Check that we return subclasses, even if a NaN scalar.c                   @   s   e Zd ZdS )z-TestMedian.test_subclass2.<locals>.MySubclassNr   r<   r<   r<   r=   
MySubclassC  s   ru  N)r6   r   rf  r   r   rC  )rb   r   ru  r  r<   r<   r=   test_subclass2?  s    zTestMedian.test_subclass2c                 C   sl   t d}t d}tt j|d|d| t d}tt j|d|d| t d}tt j||d| d S )Nr  r>  r   r  r  rL   r<   )r6   r?   r`   r'   rf  r  r<   r<   r=   r  I  s    



zTestMedian.test_outc                 C   s   t jdd t ddt td}td}tj|d< ttj	|d|d	| td
}ttj	|d|d	| td}ttj	||d	| W d    n1 s0    Y  d S )NTr1  r3  r4  r  r>  r  r   r  r  rL   r<   )
r6  r7  r8  r  r6   r?   r`   r"  r'   rf  r  r<   r<   r=   r  R  s    




zTestMedian.test_out_nanc                 C   sf  t jdtd}t j|d< tt |t j tt j|ddt j t jdtdddd}t j|d< t j|d	< tt |t j tt |jd t t jdtddddd}t j|d
< t j|d< tt |d| t t jdtddddd}t j|d< t j|d< tt |d| t t jdtddddd}t j|d< t j|d< tt |d| d S )Nr;  r   rJ   r   rw   rT   rH   r   r  r  rj   rL   r  rP   )r6   r7   rN  r"  r'   rf  rq   r   r~   r<   r<   r=   r  ^  s*    


 

 

 

zTestMedian.test_nan_behaviorzfp errors don't work correctlyr  c                 C   s  t jg td}tjddP}tddt tt |t j	 t
|d jtu  tt|d W d    n1 sp0    Y  t jg tdd	}tjddB}tddt tt |t j	 t
|d jtu  W d    n1 s0    Y  t jg tdd	}tt j|dd
| tt j|dd
| t jt j	tdd	}tjddD}tddt tt j|dd
| t
|d jtu  W d    n1 s0    Y  d S )Nr   Tr1  r3  r4  r   rJ   rT   )r   r  rw   rL   )r6   r   rN  r6  r7  r8  r  r'   rf  r"  r&   r:  r  )rb   rc   r   r   r<   r<   r=   r  ~  s&    ,0zTestMedian.test_emptyc                 C   sL   t d}ttt |tt t j|d< ttt |tt d S )Nr   rJ   )	r6   r7   r&   r   rf  r   r   rN  r"  )rb   r  r<   r<   r=   test_object  s    

zTestMedian.test_objectc              
   C   s  t jjdd}t |gd }tt j|ddt | t |dd}tt j|ddt | |dd	 }tt j|d
dt | tt j|ddt j|d d tt j|ddt j|dd tt j|ddt j|dd t 	d
d}t j|  tt j|ddd t |d d d d d d df   tt j|ddd	 t |d d d d d	d d f   tt j|ddd t |d d d d dd d f   tt j|ddd t |dd d d d d d f   tt j|ddd t |dd	d d d d f   tt j|ddd t |dd d d d d	f   tt j|ddd t |dd d dd d f   d S )Nr  r  r   r\   rw   r[   r   rk   rL   ri   rK   r  )r[   r  r  r  r  rJ   r  r  r  r  r  rO   )r6   r  r  r  r'   rf  r  r   r   r7   rq   r  r  r   r  r<   r<   r=   r    sB    $$$$   zTestMedian.test_extended_axisc                 C   sh   t 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 d S )Nr  rT  rw   r  rH   r  rQ   )r6   r`   r+   r%   rf  r_   r  r<   r<   r=   r    s    
z%TestMedian.test_extended_axis_invalidc                 C   s   t d}tt j|d ddjd tt j|dddjd tt j|dddjd tt j|d	ddjd
 tt j|dddjd tt j|dddjd d S )Nr  Tr   r   r\   r  rz   r  r  r  r  r  r	  )r6   r`   r'   rf  rA   r  r<   r<   r=   r
    s&    
zTestMedian.test_keepdimsrx   r  r  c                    s   t d|d u rdj }n*t|j t fddtjD }t |}t j|d|d}||u spJ t|j	| d S )Nr  r  c                 3   s$   | ]}| v rd nj | V  qdS r  r  rE  r  r<   r=   r    s   z/TestMedian.test_keepdims_out.<locals>.<genexpr>Tr  )
r6   r`   r   r4   r  ra   r  rf  r'   rA   )rb   rx   r  r  r  r<   r  r=   r    s    

zTestMedian.test_keepdims_outr   zm8[s]r  r  c                 C   s   t jdd|d}d||< t |}|j|ks0J t |s>J t |ddg}|j|ks\J t | snJ t jdd|ddd	}d||d
f< t j|dd}tt |g d d S r   )	r6   r7   rf  r   r"  r  r   rq   r(   r#  r<   r<   r=   test_nat_behavior  s    
zTestMedian.test_nat_behaviorN)rs   rt   ru   rf   rm  rn  r  rE  r   r  r  r6   r"  rv  r  r  r  r  r2   r  rw  r  r  r
  r  rx  r<   r<   r<   r=   ra    s4   !
	 


ra  c                   @   s.   e Zd Zejdg ddd Zdd ZdS )TestSortComplexztype_in, type_out))lr  )hr   )Hr   )r   r   )r  r   )r  r  c                 C   sH   t jg d|d}t |}t ||}t|| t|j|j d S )N)rU   rT   ro   rJ   rL   r   )r6   r   sort_complexr  r   r'   r   )rb   Ztype_inZtype_outrc   r   r  r<   r<   r=   test_sort_real  s
    


zTestSortComplex.test_sort_realc                 C   sJ   t jg ddd}t jg ddd}t |}t|| t|j|j d S )N)r        ?       r  r  r  r   )r  r  r  r  )r6   r   r}  r'   r   )rb   rc   r  r   r<   r<   r=   test_sort_complex  s
    

z!TestSortComplex.test_sort_complexN)rs   rt   ru   r   r  r  r~  r  r<   r<   r<   r=   ry    s   
ry  )r   )r   r   )}r  r6  r  r   	fractionsr   r%  r   rP  Zhypothesis.extra.numpyr   Zhypothesis.strategiesZ
strategiesrR  	functoolsr   numpyr6   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$   Znumpy.exceptionsr%   Znumpy.testingr&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   Znumpy.lib._function_base_impllibZ_function_base_implrn  Znumpy.randomr3   Znumpy._core.numericr4   r>   rF   rG   rv   r   r   r  r  r   r   r   r  r.  rR  rZ  r\  r^  rw  r  r  r  r  r  r  r  r(  r)  r*  r  r  r  r%  r  r  r  r  r  r  r  r)  r-  r4  rJ  rR  rl  r  rO  r>  r&  rV  ra  ry  r<   r<   r<   r=   <module>   s   <Dg
# <>o u  A)

   q)Ul>[j4nd` C    X  c2  &