o
    0 i                    @   s6  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 d dlmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZmZm Z m!Z!m"Z"m#Z#m$Z$ d dl%Z%dd Z&dd Z'dd Z(dd Z)dd Z*d#ddZ+dd Z,dd Z-dd  Z.d!d" Z/d#d$ Z0d%d& Z1d'd( Z2d$d)d*Z3d+d, Z4d-d. Z5d/d0 Z6d1d2 Z7d3d4 Z8d5d6 Z9d7d8 Z:d9d: Z;d;d< Z<d=d> Z=d?d@ Z>d%dAdBZ?d%dCdDZ@d&dGdHZAdIdJ ZBdKdL ZCdMdN ZDdOdP ZEdQdR ZFdSdT ZGdUdV ZHdWdX ZId'dZd[ZJd\d] ZKd'd^d_ZLd`da ZMd(dcddZNd)dedfZOd)dgdhZPdidj ZQdkdl ZRdmdn ZSd*dpdqZTd+dsdtZUdudv ZVd%dwdxZWd)dydzZXd$d{d|ZYd}d~ ZZd)ddZ[dd Z\d)ddZ]d%ddZ^d,ddZ_dd Z`d)ddZadd Zbd)ddZcdd Zdd)ddZed%ddZfd,ddZgdd Zhd)ddZid-ddZjdd Zkdd Zld.ddZmd/ddZnd0ddZodd Zpdd Zqdd Zre	jsfddZtdd Zudd Zvdd Zwdd Zxdd Zydd Zzdd Z{dd Z|ddÄ Z}ddń Z~d&ddǄZd0ddɄZdd˄ Zdd̈́ Zddτ Zd)ddфZddӄ ZddՄ Zddׄ Zddل Zddۄ Zdd݄ Zdd߄ Zd1ddZdd Zdd Zdd Zdd Zd%ddZd2ddZdd Zdd Zdd Zdd Zdd Zd3ddZdd Zd d Zd)ddZdd Zd#ddZdd	 Zd#d
dZdd Zd#ddZd#ddZd4ddZdd Zd#ddZd#ddZd4ddZG dd deeZG dd deZG d d! d!eZed"kre%  dS dS (5      N)partial)product)dedent)jitnjittypeof)types)ListDict)numpy_version)TypingError)	IS_32BITS)pysignaturecross2d)TestCaseMemoryLeakMixin
needs_blasrun_in_subprocessskip_if_numpy_2
IS_NUMPY_2IS_MACOS_ARM64c                 C   
   t | S N)npsincx r   i/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/numba/tests/test_np_functions.pyr         
r   c                 C   r   r   r   angler   r   r   r   angle1   r    r#   c                 C      t | |S r   r!   )r   degr   r   r   angle2#      r&   c                 C   r$   r   )r   array_equalabr   r   r   r(   '   r'   r(   c                 C   r$   r   r   Zintersect1dr)   r   r   r   intersect1d_2+   r'   r-   Fc                 C      t | ||S r   r,   r*   r+   assume_uniquer   r   r   intersect1d_3/      r1   c                 C      t j| ||dS Naxis)r   append)arrvaluesr6   r   r   r   r7   3      r7   c                 C      t j| |dS r4   )r   count_nonzero)r8   r6   r   r   r   r<   7   r2   r<   c                 C   r$   r   )r   delete)r8   objr   r   r   r=   ;   r'   r=   c                 C   r   r   r   diffr*   r   r   r   diff1?   r    rB   c                 C   r$   r   r?   )r*   nr   r   r   diff2C   r'   rD   c                 C   r   r   r   ZbincountrA   r   r   r   	bincount1G   r    rF   c                 C   r;   )NweightsrE   )r*   wr   r   r   	bincount2K   r2   rJ   c                 C   r.   r   rE   )r*   rI   	minlengthr   r   r   	bincount3O   r2   rL   c                 C   r$   r   r   searchsortedr*   vr   r   r   rN   S   r'   rN   c                 C      t j| |ddS )NleftsiderM   rO   r   r   r   searchsorted_leftW   r:   rU   c                 C   rQ   )NrightrS   rM   rO   r   r   r   searchsorted_right[   r:   rW   c                  G   
   t j|  S r   )r   digitizeargsr   r   r   rY   _   r    rY   c                  G   rX   r   )r   	histogramrZ   r   r   r   r\   c   r    r\   c                  G   s   t  S r   )r   ZMachArrZ   r   r   r   macharg      r]   c                 C   r   r   )r   	iscomplexr   r   r   r   r_   k   r    r_   c                 C   r   r   )r   iscomplexobjr   r   r   r   r`   o   r    r`   c                 C   r   r   )r   isscalarr   r   r   r   ra   s   r    ra   c                 C   r   r   )r   isrealr   r   r   r   rb   w   r    rb   c                 C   r   r   )r   	isrealobjr   r   r   r   rc   {   r    rc   c                 C   r$   r   )r   isneginfr   outr   r   r   rd      r'   rd   c                 C   r$   r   )r   isposinfre   r   r   r   rg      r'   rg   h㈵>:0yE>c                 C      t | ||||S r   )r   iscloser*   r+   rtolatol	equal_nanr   r   r   rk         rk   c                 C   r   r   )r   isnatr   r   r   r   rq      r    rq   c                  G   rX   r   )r   iinforZ   r   r   r   rr      r    rr   c                  G   rX   r   )r   finforZ   r   r   r   rs      r    rs   c                  G   s   t j|  jS r   )r   rs   r]   rZ   r   r   r   finfo_machar   r'   rt   c                 C   r   r   r   fliplrrA   r   r   r   rv      r    rv   c                 C   r   r   r   flipudrA   r   r   r   rx      r    rx   c                 C   r   r   )r   fliprA   r   r   r   ry      r    ry   c                 C   r$   r   r   Zlogspacestartstopr   r   r   	logspace2   r'   r~   2   c                 C   r3   Nnumrz   r|   r}   r   r   r   r   	logspace3   r:   r   c                 C   r$   r   r   Z	geomspacer{   r   r   r   
geomspace2   r'   r   c                 C   r3   r   r   r   r   r   r   
geomspace3   r:   r   c                 C   r   r   r   rot90rA   r   r   r   r      r    r      c                 C   r$   r   r   )r*   kr   r   r   rot90_k   r'   r   c                 C   r3   r4   )r   array_splitr*   indicesr6   r   r   r   r      r:   r   c                 C   r3   r4   )r   splitr   r   r   r   r      r:   r   c                 C   r$   r   )r   vsplitr*   
ind_or_secr   r   r   r      r'   r   c                 C   r$   r   )r   hsplitr   r   r   r   r      r'   r   c                 C   r$   r   )r   dsplitr   r   r   r   r      r'   r   validc                 C   r3   Nmode)r   	correlater*   rP   r   r   r   r   r      r:   r   fullc                 C   r3   r   )r   convolver   r   r   r   r      r:   r   c                 C   r   r   r   ZtriNr   r   r   tri_n   r    r   c                 C   r$   r   r   r   Mr   r   r   tri_n_m   r'   r   c                 C   r$   r   r   r   r   r   r   r   tri_n_k   r'   r   c                 C   r.   r   r   r   r   r   r   r   r   	tri_n_m_k   r2   r   c                 C   r   r   r   Ztrilmr   r   r   tril_m   r    r   c                 C   r$   r   r   r   r   r   r   r   tril_m_k   r'   r   c                 C   r   r   r   Ztril_indicesrC   r   r   r   tril_indices_n   r    r   c                 C   r$   r   r   rC   r   r   r   r   tril_indices_n_k   r'   r   c                 C   r;   Nr   r   rC   r   r   r   r   tril_indices_n_m   r2   r   c                 C   r.   r   r   rC   r   r   r   r   r   tril_indices_n_k_m   r2   r   c                 C   r   r   r   Ztril_indices_fromr8   r   r   r   tril_indices_from_arr  r    r   c                 C   r$   r   r   r8   r   r   r   r   tril_indices_from_arr_k  r'   r   c                 C   r   r   r   Ztriur   r   r   r   triu_m  r    r   c                 C   r$   r   r   r   r   r   r   triu_m_k  r'   r   c                 C   r   r   r   Ztriu_indicesr   r   r   r   triu_indices_n  r    r   c                 C   r$   r   r   r   r   r   r   triu_indices_n_k  r'   r   c                 C   r;   r   r   r   r   r   r   triu_indices_n_m  r2   r   c                 C   r.   r   r   r   r   r   r   triu_indices_n_k_m  r2   r   c                 C   r   r   r   Ztriu_indices_fromr   r   r   r   triu_indices_from_arr#  r    r   c                 C   r$   r   r   r   r   r   r   triu_indices_from_arr_k'  r'   r   c                 C   r.   r   )r   vanderr   r   
increasingr   r   r   r   +  r2   r   c                 C   r$   r   )r   	partitionr*   kthr   r   r   r   /  r'   r   c                 C   r$   r   )r   argpartitionr   r   r   r   r   3  r'   r   Tc                 C   rj   r   )r   cov)r   yrowvarbiasddofr   r   r   r   7  rp   r   c                 C   r.   r   )r   corrcoefr   r   r   r   r   r   r   ;  r2   r   c                 C   r.   r   )r   ediff1d)aryto_endto_beginr   r   r   r   ?  r2   r   c                 C   r$   r   )r   roll)r*   shiftr   r   r   r   C  r'   r   c                 C   r   r   r   asarrayrA   r   r   r   r   G  r    r   c                 C   r;   Ndtyper   r*   r   r   r   r   asarray_kwsK  r2   r   c                 C   r;   r   r   asfarrayr   r   r   r   r   O  r2   r   c                 C   r   r   r   rA   r   r   r   asfarray_default_kwargS  r    r   c                 C   r$   r   )r   extract	conditionr8   r   r   r   r   W  r'   r   c                 C   r   r   r   Ztrapzr   r   r   r   np_trapz[  r    r   c                 C   r$   r   r   r   r   r   r   r   
np_trapz_x_  r'   r   c                 C   r;   Ndxr   r   r   r   r   r   np_trapz_dxc  r2   r   c                 C   r.   r   r   r   r   r   r   r   r   np_trapz_x_dxg  r2   r   c                 C   r   r   r   Z	trapezoidr   r   r   r   np_trapezoidk  r    r   c                 C   r$   r   r   r   r   r   r   np_trapezoid_xo  r'   r   c                 C   r;   r   r   r   r   r   r   np_trapezoid_dxs  r2   r   c                 C   r.   r   r   r   r   r   r   np_trapezoid_x_dxw  r2   r   c                 C   rj   r   )r   Zallcloserl   r   r   r   np_allclose{  rp   r   c                 C   r3   )Nr6   rH   )r   Zaverage)r*   r6   rH   r   r   r   
np_average  r:   r   c                 C   r.   r   )r   interpr   xpfpr   r   r   r     r2   r   c                 C   r$   r   )r   repeatr*   repeatsr   r   r   	np_repeat  r'   r  c                 C   s   t | |S r   )r   r   r  r  r   r   r   array_repeat  r:   r  c                 C   r3   )N)defaultr   select)condlist
choicelistr  r   r   r   	np_select  r:   r  c                 C   r$   r   r  )r
  r  r   r   r   np_select_defaults  r'   r  c                 C   r   r   )r   Zbartlettr   r   r   r   np_bartlett  r    r  c                 C   r   r   )r   Zblackmanr  r   r   r   np_blackman  r    r  c                 C   r   r   )r   Zhammingr  r   r   r   
np_hamming  r    r  c                 C   r   r   )r   Zhanningr  r   r   r   
np_hanning  r    r  c                 C   r$   r   )r   Zkaiser)r   betar   r   r   	np_kaiser  r'   r  c                 C   r$   r   )r   crossr)   r   r   r   np_cross  r'   r  fbc                 C   r$   r   )r   Z
trim_zeros)r*   trimr   r   r   np_trim_zeros  r'   r  c                 C   s
   t | |S r   r   r)   r   r   r   
nb_cross2d  r    r  c                 C   r   r   ru   rA   r   r   r   flip_lr  r    r  c                 C   r   r   rw   rA   r   r   r   flip_ud  r    r  c                 C   r$   r   )r   Zunion1dr)   r   r   r   
np_union1d  r'   r  c                 C   r$   r   )r   Zasarray_chkfiniter   r   r   r   np_asarray_chkfinite  r'   r  -DT!@c                 C   s   t j| |||dS Nperiodr   unwrap)pdiscontr6   r#  r   r   r   r%    rp   r%  c                 C   r   r   r$  )r&  r   r   r   unwrap1  r    r(  c                 C   r;   r!  r$  )r&  r#  r   r   r   unwrap13  r2   r)  c                 C   r3   )Nr#  r'  r$  )r&  r#  r'  r   r   r   	unwrap123  r:   r+  c                 C   s   || v S r   r   )r*   keyr   r   r   array_contains  r^   r-  c                 C   r.   r   )r   swapaxes)r*   a1a2r   r   r   r.    r2   r.          c                 C   r3   )Ncopynan)r   
nan_to_num)Xr3  r4  r   r   r   r5    r:   r5  c                 C   r   r   )r   r   )
dimensionsr   r   r   
np_indices  r    r8  c                 C   r   r   r   Zdiagflat)rP   r   r   r   	diagflat1  r    r:  c                 C   r$   r   r9  )rP   r   r   r   r   	diagflat2  r'   r;  c                 C   r$   r   r   Zsetxor1dr)   r   r   r   np_setxor1d_2  r'   r=  c                 C   r.   r   r<  r/   r   r   r   np_setxor1d_3  r2   r>  c                 C   r$   r   r   Z	setdiff1dr)   r   r   r   np_setdiff1d_2  r'   r@  c                 C   r.   r   r?  r/   r   r   r   np_setdiff1d_3  r2   rA  c                 C   r$   r   r   Zin1dr)   r   r   r   	np_in1d_2  r'   rC  c                 C   r3   Nr0   rB  r/   r   r   r   
np_in1d_3a  r:   rF  c                 C   r3   NinvertrB  r*   r+   rI  r   r   r   
np_in1d_3b  r:   rK  c                 C      t | |||S r   rB  r*   r+   r0   rI  r   r   r   	np_in1d_4  r:   rN  c                 C   r$   r   r   isinr)   r   r   r   	np_isin_2  r'   rQ  c                 C   r3   rD  rO  r/   r   r   r   
np_isin_3a  r:   rR  c                 C   r3   rG  rO  rJ  r   r   r   
np_isin_3b  r:   rS  c                 C   rL  r   rO  rM  r   r   r   	np_isin_4  r:   rT  c                       s	  e Zd ZdZ fddZ		dd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d0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Z d>d? Z!d@dA Z"dBdC Z#dDdE Z$dFdG Z%dHdI Z&dJdK Z'dLdM Z(dNdO Z)dPdQ Z*dRdS Z+dTdU Z,dVdW Z-dXdY Z.dZd[ Z/d\d] Z0d^d_ Z1d`da Z2dbdc Z3ddde Z4ddfdgZ5dhdi Z6djdk Z7dldm Z8dndo Z9dpdq Z:drds Z;dtdu Z<dvdw Z=dxdy Z>e?dzd{ Z@d|d} ZAd~d ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdddZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd ZcddĄ ZdddƄ ZeddȄ Zfddʄ Zgdd̄ Zhdd΄ ZiddЄ Zjdd҄ ZkddԄ Zlddք Zmdd؄ Zneoddڄ Zpdd܄ Zqeoddބ Zreodd Zseodd Zteodd Zudd Zveodd Zweodd Zxeodd Zyeodd Zzdd Z{dd Z|dd Z}dd Z~dd Zdd Zdd Zdd Zd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* Zeed+d,d- Zefd.d/Zeed+d0d1 Zefd2d3Zeed+d4d5 Zed6efd7d8Zeed+d9d: Zefd;d<Zeed+d=d> Zefd?d@Zeed+dAdB ZefdCdDZdEdF ZdGdH ZdIdJ ZdKdL ZdMdN ZdOdP ZdQdR ZdSdT ZdUdV ZdWdX ZdYdZ Zd[d\ Zd]d^ Zeeosed_d`da Zdbdc Zddde Zdfdg Zdhdi Zdjdk Zdldm Zdndo ZÐdpdq ZĐdrds ZeƐdtdu Zǐdvdw ZȐdxdy Zɐdz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d Zdd Zdd Ze?dd Zdd Zdd Zdd Ze?dd Zdd Zdd Zdd Ze?dd ZddÄ ZdĐdń ZdƐdǄ ZdȐdɄ Zdʐd˄ Ze?d̐d̈́ Zdΐdτ ZdАdф ZdҐdӄ ZdԐdՄ Zd֐dׄ Zdؐdل Z  ZS (  TestNPFunctionsz,
    Tests for various Numpy functions.
    c                    s    t t|   tjd| _d S )N*   )superrU  setUpr   randomZRandomStaterndself	__class__r   r   rX  $  s   zTestNPFunctions.setUpNFc              
   K   s   t ||D ]b\}	}
|du rdg }}t ||D ]O\}}t|	f| |}||
g|R  }||
g|R  }z|	j}W n tyD   |	}Y nw |tjtjfv rOdnd}d|
|f }| j||f||||d| qqdS )aC  
        Runs tests for a unary function operating in the numerical real space.

        Parameters
        ----------
        pyfunc : a python function definition holding that calls the numpy
                 functions to be tested.
        x_types: the types of the values being tested, see numba.types
        x_values: the numerical values of the values to be tested
        func_extra_types: the types of additional arguments to the numpy
                          function
        func_extra_args:  additional arguments to the numpy function
        ignore_sign_on_zero: boolean as to whether to allow zero values
        with incorrect signs to be considered equal
        prec: the required precision match, see assertPreciseEqual

        Notes:
        ------
        x_types and x_values must have the same length

        Nr   singledoublezfor input %r with prec %r)precmsgignore_sign_on_zeroabs_tol)zipr   r   AttributeErrorr   float32	complex64assertPreciseEqual)r\  pyfuncx_typesx_valuesfunc_extra_typesfunc_extra_argsrc  rd  kwargsZtxZvxZxtypesZxargscfuncgotexpectedZscaltyra  rb  r   r   r   	run_unary(  s6   


zTestNPFunctions.run_unaryc                    s   d dt  fdd}g d}tjtjgt|d  }||| tj|tjdg}dd	 |D }||| g d
}tjtjgt|d  }|||dd tj|tjdg}dd	 |D }|||dd dS )zv
        Tests the sinc() function.
        This test is purely to assert numerical computations are correct.
        Tepsc                    s    j | |f d| d S )N)rc  rd  )rs  )rk  rl  ro  Zisozrj  r\  Ztolr   r   checkq  s
   
z(TestNPFunctions.test_sinc.<locals>.check)
      ?      r1               ?         g#B;g#B   r   c                 S      g | ]}t |qS r   r   .0rP   r   r   r   
<listcomp>}      z-TestNPFunctions.test_sinc.<locals>.<listcomp>)      ?                                      r                ?y                    ?                            ?      ?                  @      @            y#B;        y#B        y        #B;y        #B)ulpsc                 S   r  r   r  r  r   r   r   r    r  N)	r   r   rg  float64lenr   arrayrh  
complex128r\  rv  rl  rk  r   ru  r   	test_sincU  s    	

zTestNPFunctions.test_sincc                 C   b   t }tdd|}| t}|d W d    n1 sw   Y  | dt|j |   d S )NTZnopythonstrz+Argument "x" must be a Number or array-like)r   r   assertRaisesr   assertInr  	exceptiondisable_leak_checkr\  rj  rp  raisesr   r   r   test_sinc_exceptions     
z$TestNPFunctions.test_sinc_exceptionsc                 C   N   dd }t }tdd|}| D ]\}}|||}|||}| || qd S )Nc                  s   s8   t dd} d}| |fV  t d}d}||fV  t dg}d}d}||fV  ||fV  t g }||fV  t ddg}|dfV  ||fV  t jd t jd}	t jd t j }
|	d	 }|	|
fV  |	|fV  |	t j}||d	 fV  ||
fV  t jd t jj	dd
t j
d}|dfV  |dfV  d S )N
   r            TFr~  r      )sizer   r|     )r   aranger   r  rY  seedrandviewr  randintuint8)Za_0Zk_0Za_1Zk_1Zsingle_val_aZk_inZk_outZ	empty_arrZbool_arrZ	float_arrZrand_kZ	present_kZ
complx_arrZuint_arrr   r   r   arrs  s>   













z+TestNPFunctions.test_contains.<locals>.arrsTr  )r-  r   ri  )r\  r  rj  rp  r8   r,  rr  Zreceivedr   r   r   test_contains  s   -

zTestNPFunctions.test_containsc                    s   t  t fdd}g d}tjtjgt|d d  }||| tj|tjdg}dd |D }||| g d	}tjtj	gt|d d  }||| t|}tjtj	g}||| d
S )zw
        Tests the angle() function.
        This test is purely to assert numerical computations are correct.
        c                    s@     | | ddg}tjfgt| }j | |||d d S )NTF)rm  rn  )rs  r   bool_r  )rk  rl  Zxtra_valuesZ
xtra_typespyfunc1pyfunc2r\  r   r   rv    s   

z)TestNPFunctions.test_angle.<locals>.check)rw  rx  r1  ry  rz  r{  r|  r}  r~  r   r   c                 S   r  r   r  r  r   r   r   r    r  z.TestNPFunctions.test_angle.<locals>.<listcomp>)r  r  r  r  r  y             r  r  r  r  r  r  N)
r#   r&   r   rg  r  r  r   r  rh  r  r  r   r  r   
test_angle  s   



zTestNPFunctions.test_anglec                 C   sn   dd }|}g d}g d}t ||D ]!\}}tj|g|d}tdd|}||}	||}
| |	|
 qd S )Nc                 S   s   t | }|jS r   )r   r"   r   )r   rr   r   r   numba_angle  s   
z;TestNPFunctions.test_angle_return_type.<locals>.numba_angle)rw  rx  r  r  )Zf4Zf8Zc8Zc16r   Tr  )re  r   r  r   assertEqual)r\  r  rj  rl  rk  valtypr   rp  rr  rq  r   r   r   test_angle_return_type  s   z&TestNPFunctions.test_angle_return_typec                 C   r  )NTr  helloz0Argument "z" must be a complex or Array[complex])r#   r   r  r   r  r  r  r  r  r   r   r   test_angle_exceptions  r  z%TestNPFunctions.test_angle_exceptionsc                 C   r  )Nc                  s   s    t g t g fV  t ddgt ddgfV  t g t dgfV  t ddd} d| d d< t ddd| fV  | | fV  dV  dV  dV  d	V  d
V  dV  dV  dV  d S )Nr   r~  r  r|     r   r~     r  r~  r~  )r  r~  )TTTF)Tr~  )Tr   )Fr   r   r  r  reshaper   r   r   r   arrays  s    

z0TestNPFunctions.test_array_equal.<locals>.arraysTr  )r(   r   ri  r\  r  rj  rp  r8   r>   rr  rq  r   r   r   test_array_equal  s   

z TestNPFunctions.test_array_equalc                 C   sj   t }tdd|}| t}|tdddd  W d    n1 s%w   Y  | dt|j	 d S )NTr     r     z3Both arguments to "array_equals" must be array-like)
r(   r   r  r   r   r  r  r  r  r  r  r   r   r   test_array_equal_exception-  s   z*TestNPFunctions.test_array_equal_exceptionc                 C   sr   dd }t }tdd|}| D ]&\}}t|trt|}t|tr&t|}|||}|||}| || qd S )Nc                   s       t tjt tjfV  dgt tjfV  t tjdgfV  dgdgfV  dgdgfV  ddgdgfV  g dddgfV  ddgddgfV  g dg dfV  g dg dfV  g dg dfV  d S 	Nr   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	   
empty_listr   r  r   r   r   r   r  :     

z2TestNPFunctions.test_intersect1d_2.<locals>.arraysTr  )r-   r   
isinstancelistr	   ri  r\  r  rj  rp  r*   r+   rr  rq  r   r   r   test_intersect1d_28  s   



z"TestNPFunctions.test_intersect1d_2c                 C   s   dd }t }tdd|}| D ]T\}}t|trt|}t|tr&t|}|||dd}|||dd}| || tt|t|krdtt|t|krd|||dd}|||dd}| || qd S )Nc                   s   r  r  r  r   r   r   r   r  Z  r  z2TestNPFunctions.test_intersect1d_3.<locals>.arraysTr  FrE  )	r1   r   r  r  r	   ri  r  r   uniquer  r   r   r   test_intersect1d_3X  s"   

,z"TestNPFunctions.test_intersect1d_3c                 C      t }t|}tdg}tdg}|   | t |||d W d    n1 s,w   Y  | t |d|d W d    n1 sGw   Y  | t ||dd W d    d S 1 scw   Y  d S Nr   r~  fooT)r1   r   r   r  r  r  r   r\  	np_pyfunc	np_nbfuncr*   r+   r   r   r   test_intersect1d_errorsz     "z'TestNPFunctions.test_intersect1d_errorsc                 C   r  )Nc                   s   s    t g d fV  t dd fV  t dd fV  t jdt jddfV  t ddddd fV  t ddddfV  t dddd	fV  d S )
Nr  r   r   <   r  r  r|  r  r   )r   r  zerosr  onesr  r  r   r   r   r   r    s   z2TestNPFunctions.test_count_nonzero.<locals>.arraysTr  )r<   r   ri  )r\  r  rj  rp  r8   r6   rr  rq  r   r   r   test_count_nonzero  s   	

z"TestNPFunctions.test_count_nonzeroc           	      C   sT   dd }t }tdd|}| D ]\}}}||||}||||}| || qd S )Nc                  s   s    dV  t ddd fV  t dt dd fV  t dddt dd fV  t g dg dgt g dgd	fV  t g dg dg} | | d
fV  d S )N)r~  r~  Nr  r  r|  r~  r  r  r|  r  r     	   r   r   )r   r  r  r  r   r   r   r   r    s    *z.TestNPFunctions.test_np_append.<locals>.arraysTr  )r7   r   ri  )	r\  r  rj  rp  r8   r>   r6   rr  rq  r   r   r   test_np_append  s   	zTestNPFunctions.test_np_appendc                 C   s"  t }tdd|}tg dg dg}tg dg}d}| t}|d || W d    n1 s4w   Y  | dt|j | t}||d | W d    n1 sXw   Y  | dt|j | t}|||d	d
 W d    n1 s}w   Y  | dt|j | 	  d S )NTr  r  r  r  r   z+The first argument "arr" must be array-likez/The second argument "values" must be array-liker1  r5   z,The third argument "axis" must be an integer)
r7   r   r   r  r  r   r  r  r  r  )r\  rj  rp  r8   r9   r6   r  r   r   r   test_np_append_exceptions  s6   z)TestNPFunctions.test_np_append_exceptionsc                 C   r  )Nc                   s   s    g ddfV  g dddgfV  t ddfV  t ddfV  t dg dfV  t dg dfV  t ddd	d
dfV  t ddd	d
g dfV  g dtdddfV  t dtdfV  d S )Nr   r~  r  r  r|  r  r~  r  )r  r|  r  )r~  r  r  r|  r  r  r|  )r|  r     r  r   r~  r  r  r   )r   r  r  slicer   r   r   r   r    s   z+TestNPFunctions.test_delete.<locals>.arraysTr  )r=   r   ri  r  r   r   r   test_delete  s   

zTestNPFunctions.test_deletec                 C   sP  t }tdd|}|   | t}|ddgd W d    n1 s$w   Y  | dt|j | t}|t	dg d W d    n1 sLw   Y  | dt|j | t}|dd	 W d    n1 sow   Y  | d
t|j | t
}|ddgd	 W d    n1 sw   Y  | dt|j |   d S )NTr  r   r~  gQ	@zobj should be of Integer dtyper  )g      @gffffff@g@r  z)arr must be either an Array or a Sequencez"obj must be less than the len(arr))r=   r   r  r  r   r  r  r  r   r  
IndexErrorr  r   r   r   test_delete_exceptions  s@   z&TestNPFunctions.test_delete_exceptionsc                 c   sD    t dd }|V  |d}|V  t ddd }|V  dS )z0
        Some test arrays for np.diff()
        r  r  r  r     )r  r~  r  Nr   r  r  r\  r*   r+   cr   r   r   diff_arrays  s   

zTestNPFunctions.diff_arraysc                 C   s|   t }tdd|}|  D ]}||}||}| || qtd}|   || W d    d S 1 s7w   Y  d S )NTr  rV  )rB   r   r  ri  r   r  assertTypingError)r\  rj  rp  r8   rr  rq  r*   r   r   r   
test_diff1  s   


"zTestNPFunctions.test_diff1c              	   C   sp   t }tdd|}|  D ](}|jd }dddd|d ||d dfD ]}|||}|||}| || q"qd S )	NTr  r  r   r   r~  r  i  )rD   r   r  shaperi  )r\  rj  rp  r8   r  rC   rr  rq  r   r   r   
test_diff2'  s   
 

zTestNPFunctions.test_diff2c              	   C   s   t }tdd|}|   td}|   ||d W d    n1 s&w   Y  td}dD ]%}| t}||| W d    n1 sIw   Y  | 	dt
|j q2|   d S )NTr  rV  r   r  )r  izorder must be non-negative)rD   r   r  r   r  r  r  r  
ValueErrorr  r  r  )r\  rj  rp  r8   rC   r  r   r   r   test_diff2_exceptions1  s   


z%TestNPFunctions.test_diff2_exceptionsc                 C   sH   dd }t }tdd|}| D ]}||}||}| ||| qd S )Nc                   s   s|    dV  t dgV  dV  dV  dV  tdV  t dV  dV  dV  d V  t dd	V  t d
V  t dd	V  d S )Nr  )r                @numbar  i90  gV-@TYZnatr   )r   r   intint16timedelta64
datetime64r   r   r   r   r9   G  s   
z-TestNPFunctions.test_isscalar.<locals>.valuesTr  )ra   r   r  r\  r9   rj  rp  r   rr  rq  r   r   r   test_isscalarF  s   
zTestNPFunctions.test_isscalarc                 C   s   dd }t dddd }ttg}|D ]L}t dd|}| D ]6}||}||}| || ||d|}	||d|}
| |	|
 ||d|}||d|}| || q| t|jd qd S )	Nc                   s   s(    dV  dV  t g dV  dV  d S )Nr   r  )r  r  Thello worldr   r   r   r   r   r9   ^  s
   
z4TestNPFunctions.test_isobj_functions.<locals>.valuesTr  c                 S   s   |r| nd }||S r   r   )r   condrp  r   r   r   r   optional_fnd  s   z9TestNPFunctions.test_isobj_functions.<locals>.optional_fnFr  )r   r`   rc   r  py_funcr  Z
signatures)r\  r9   r  pyfuncsrj  rp  r   rr  rq  Zexpected_optionalZgot_optionalZexpected_noneZgot_noner   r   r   test_isobj_functions]  s$   

z$TestNPFunctions.test_isobj_functionsc                 C   sT   dd }t tg}|D ]}tdd|}| D ]}||}||}| || qq
d S )Nc                   s   sh    t g dV  t g dV  dV  dV  dV  dV  dV  t dd	gdd
gddgddggV  d S )N)      ?      ?r        @r  r~                 @r  r  y              (@      ?      @y      $@        )r  y       @        r   r~  r  r|  r  r  r  r   r  r   r   r   r   r9   ~  s   (z7TestNPFunctions.test_is_real_or_complex.<locals>.valuesTr  )r_   rb   r   ri  )r\  r9   r  rj  rp  r   rr  rq  r   r   r   test_is_real_or_complex}  s   

z'TestNPFunctions.test_is_real_or_complexc           	      C   s\   dd }t tg}|D ]!}tdd|}| D ]\}}|||}|||}| || qq
d S )Nc                   s   s    t j d fV  t jd fV  t jd fV  t t j dt jgd fV  t j t jdt jdfV  t jt jdt jdfV  t jt jdt jdfV  t j t dfV  t t j dt jgt jdt jdfV  d S )Nr1  r   r   r  r  )r   infr   r  r  emptyr   r   r   r   r9     s   ,z7TestNPFunctions.test_isneg_or_ispos_inf.<locals>.valuesTr  )rd   rg   r   ri  )	r\  r9   r  rj  rp  r   rf   rr  rq  r   r   r   test_isneg_or_ispos_inf  s   

z'TestNPFunctions.test_isneg_or_ispos_infc           	         s   ddt ddgt dd d fdd	}t}td
d|}| D ]-\}}}|||fi |}|||fi |}t|t jrR| || q.| 	t 
|| q.d S )Nrh   ri   d     r  r~  r~  r~  )rm   rn   c                   3   sp   ddi fV  dt ji fV  t ddgt ddgi fV  t ddgt ddgi fV  t ddgt ddgi fV  t ddgt ddgi fV  t dt jgt dt jgi fV  t dt jgt dt jgd	d
ifV  t t jt jgt dt jgd	d
ifV  t ddgt ddgddifV  t ddgt ddgi fV  t ddgt ddgddifV  t dt jdgt dt jdgfV  t t jt j t jgt dgfV  t t jt j t jgdfV  dt t jt j t jgfV  t ddgt ddgfV  fV  t dgt d  gfV    fV     fV       fV  t jt jfV  t j t jfV  t jt t jgfV  t t jt j gt t jt j gfV  t t jdgt dt jgfV  t t jt j gt ddgfV  t t jt jgt dt j gfV  t t jt jgt ddgfV  t t jdgt t jt j gfV  t d gt dgfV  t dgt d d  gfV    d    d  fV  t t t jdgt t dt jgfV  t t jdgt d d gfV  t t jdgt t jd gfV  t dddd    gt dt jdgfV  t dt g dfV  t jt t jt jt jgfV  t dgt t jt j t jgfV  dt t jt j t jgfV  d S )N    _B   UkBri   Hz>r1  &.>   2٠Brw  ro   T0.++rn   绽|=g#B;g=|=r   r~  r  r  r   皙?    .A)r   r    @)r   r4  r  r  r  r   aranr8   rn   kwrm   r   r   r9     sV       $(*$ $(*"" $,$&($( ( 0*(6 *&z,TestNPFunctions.test_isclose.<locals>.valuesTr  )r   r  r  r  rk   r   r  r  r  
assertTruer(   )	r\  r9   rj  rp  r*   r+   ro  rr  rq  r   r)  r   test_isclose  s   
5zTestNPFunctions.test_isclosec                 C   s   t }tdd|}tddtjgtddgdddd	tfd
dddddtfdd
ddddtfddddddtfddddddtfddddddtfg}|D ]'\}}}}}}	}
| |
|	 |||||| W d    n1 skw   Y  qId S NTr  r  r"  r#  rh   ri   Fz=shape mismatch: objects cannot be broadcast to a single shaper  r  z)The first argument "a" must be array-likez*The second argument "b" must be array-liker~  z2The third argument "rtol" must be a floating pointz3The fourth argument "atol" must be a floating pointr   z0The fifth argument "equal_nan" must be a boolean)rk   r   r   r   r4  r  r   assertRaisesRegexr\  rj  rp  Zinpsr*   r+   rm   rn   ro   Zexc_msgexcr   r   r   isclose_exception  sF   




z!TestNPFunctions.isclose_exceptionc                 C   s:   g d}t g d}| jjddddt j}|||fS )z7
        Some test sequences for np.bincount()
        )r   r~  r|  r~  r  r  )r|  r  rV  r|  r   r  ,  r  )r   r  rZ  r  astypeint8r  r   r   r   bincount_sequences  s   
z"TestNPFunctions.bincount_sequencesc                 C   s@   t }tdd|}|  D ]}||}||}| || qd S NTr  )rF   r   r7  ri  )r\  rj  rp  seqrr  rq  r   r   r   test_bincount1  s   zTestNPFunctions.test_bincount1c                 C   sn   t }tdd|}|   | t}|ddg W d    n1 s#w   Y  | dt|j |   d S )NTr  r~  r  #first argument must be non-negative)rF   r   r  r  r  r  r  r  r  r   r   r   test_bincount1_exceptions  s   z)TestNPFunctions.test_bincount1_exceptionsc                 C   sp   t }tdd|}|  D ](}dd |D }|t||t|fD ]}|||}|||}| || q"qd S )NTr  c                 S   s   g | ]	}t |d  qS r~  )mathsqrtr  r   r   r   r   r  ,  s    z2TestNPFunctions.test_bincount2.<locals>.<listcomp>)rJ   r   r7  r   r  ri  )r\  rj  rp  r9  rI   rH   rr  rq  r   r   r   test_bincount2(  s   

zTestNPFunctions.test_bincount2c                 C   s   t }tdd|}|   | t}|ddgddg W d    n1 s&w   Y  | dt|j | t}|ddgdg W d    n1 sLw   Y  | dt|j d S )NTr  r~  r  r   r;  z+weights and list don't have the same length)rJ   r   r  r  r  r  r  r  r  r   r   r   test_bincount2_exceptions3     z)TestNPFunctions.test_bincount2_exceptionsc                 C   sv   t }tdd|}|  D ]+}t|}||d fD ]}||d |}||d |}| t|t| | || qqd S )NTr  r~  )rL   r   r7  maxr  r  ri  )r\  rj  rp  r9  Za_maxrK   rr  rq  r   r   r   test_bincount3F  s   zTestNPFunctions.test_bincount3c                 C   s   t }tdd|}|   | t}|ddgddg W d    n1 s&w   Y  | dt|j | t}|ddgd d W d    n1 sLw   Y  | d	t|j d S )
NTr  r~  r  r   r;     &   z 'minlength' must not be negative)rL   r   r  r  r  r  r  r  r  r   r   r   test_bincount3_exceptionsR  rC  z)TestNPFunctions.test_bincount3_exceptionsc                    sL  t tdd ttddttdd fdd}tdd }tdd }|t|fD ]"}|D ]}||| q?||d	fD ]}||| qN||t| q;tt|t	d
gd  d }tdd }|t|fD ]"}|D ]}||| q||d	fD ]}||| q||t| q{dd }tdd| 
   ddgd W d    n1 sw   Y  ddd}tdd| 
   ddgddd W d    n1 sw   Y  tg d}tddgddgddgddgg}||| tg d}tddgddgddgg}||| d S )NTr  c                    d   | |} | |} || | |}| |} || | |}| |} || d S r   ri  r*   rP   rr  rq  rp  Z
cfunc_leftZcfunc_rightrj  Zpyfunc_leftZpyfunc_rightr\  r   r   rv  o     





z0TestNPFunctions.test_searchsorted.<locals>.checkr|  r~  r  r   r  r|  r4  r         @rz  c                 S   rQ   )NZnonsenserS   rM   rO   r   r   r   bad_side  r:   z3TestNPFunctions.test_searchsorted.<locals>.bad_siderR   c                 S   r3   )NrS   rM   )r*   rP   rT   r   r   r   nonconst_side  r:   z8TestNPFunctions.test_searchsorted.<locals>.nonconst_siderV   rS   )r   r~  r   r  r  r   r  )	r  r   r  r~  r   r  r  r  r  r  r  )rR   )rN   r   rU   rW   r   r  r  r  r  floatr  r  )r\  rv  binsr9   r*   rP   rP  rQ  r   rL  r   test_searchsortede  sd    



z!TestNPFunctions.test_searchsortedc           	         s  t tdd ttddttdd fdd}ttdd}|tjgd tjgd  tj gd  7 }td	D ]+}j	
g d
}j	
||}j	
|||d d  }||| |t|| qGtd}tjt|tjd}||| ||| ||| ||| td}td}||| tg d}tddg}||| g d}d}||| tg d}tddg}||| d S )NTr  c                    rI  r   rJ  rK  rL  r   r   rv    rM  z=TestNPFunctions.test_searchsorted_supplemental.<locals>.checkr}  r   r|  r  r  )r|  r  r  r   Z
fill_valuer   )FFTTFr  )123rW  4)rN   r   rU   rW   r  ranger   r4  r  rZ  choicesortr  r   r  r  r  )	r\  rv  element_poolisample_sizer*   rP   r  nansr   rL  r   test_searchsorted_supplemental  sB   *










z.TestNPFunctions.test_searchsorted_supplementalc                    s   t tdd ttddttdd fdd}ddtjg}dd t||D }td	D ].}j	
d
dt|g}j	
||}j	
|||d
 d  }||| |t|| q<|t|tdd d S )NTr  c                    rI  r   rJ  rK  rL  r   r   rv    rM  z8TestNPFunctions.test_searchsorted_complex.<locals>.checkr   r   c                 S   s   g | ]}t | qS r   )complex)r  r  r   r   r   r    r  z=TestNPFunctions.test_searchsorted_complex.<locals>.<listcomp>r  r  r|  r~  rO   )rN   r   rU   rW   r   r4  	itertoolsr   rZ  rZ  r[  r  r\  r  r  )r\  rv  poolr]  r^  r_  r*   rP   r   rL  r   test_searchsorted_complex  s    
z)TestNPFunctions.test_searchsorted_complexc                    s  t tdd  fdd}tddddd	d
dddtdtdtdf}t|dks0J j| tg d}tddd	dtdtdg}tddd	dtdtdgtdgd  }|||g}||dg}|D ]}|	  |D ]}	||	| ||	|d d d  qxqp|D ]}dD ]}
||||
 |||d d d |
 qq|t
|| |ttjdgtdtjg d S )NTr  c                         |  } |  } || d S r   rJ  r[   rr  rq  rp  rj  r\  r   r   rv  *     z,TestNPFunctions.test_digitize.<locals>.checkr   Gz?r   皙@r  r  r  r        #@r  z-infr4  r  r   r  r  r  r  r  r  r  r        ?)rY   r   r   r  rR  r  rZ  shuffler  r\  r  r  r4  )r\  rv  r9   Zbins1Zbins2Zbins3Zall_binsxsrS  r   rV   r   rh  r   test_digitize&  s8   

&zTestNPFunctions.test_digitizec                    s      ttdd  fdd}ttjdg}ttjddtjg}||| g d}g d	}||| g d
}||| d S )NTr  c               	      sZ    fD ]&} t}||   W d    n1 sw   Y  d}|t|j qd S )Nz3bins must be monotonically increasing or decreasingr  r  r  r  r  )r[   fnr  rb  rh  r   r   check_errorV  s   
zETestNPFunctions.test_digitize_non_monotonic_bins.<locals>.check_errorr   rn  ffffff@r  r   r   r~  )r   r   r   r   r   r   r   r   )r  rY   r   r   r  r4  )r\  rt  r   rS  r   rh  r    test_digitize_non_monotonic_binsO  s   

z0TestNPFunctions.test_digitize_non_monotonic_binsc                    s  t tdd  fdd}tdd}tdd}||| tddd}tddd}||| jd	}t| | d	}||| g d
}g d}||| tdd}tdd}|||d tddd}tddd}|||d jd	}t| | d	}|||d g d}g d}||| g d}||| g d}||| d}||g|d |d g d S )NTr  c                     rf  r   rJ  rg  rh  r   r   rv  p  ri  z9TestNPFunctions.test_digitize_supplemental.<locals>.checkr|  r}  r  r  )r   r|  r  r  r     r   )r   r|  r  r  rv  )r   r   r   )r   r   r   r   r   r   r   l          r   )	rY   r   r   r  rZ  r  linspaceminrD  )r\  rv  r   rS  r   rh  r   test_digitize_supplementali  sB   






z*TestNPFunctions.test_digitize_supplementalc              	   C   s   |    t}tdd|}tdg}tg d}d}||fD ]$}|  }||| | |t|j W d    n1 s?w   Y  q d S )NTr  r  )rw        @r         @zx may not be complex)	r  rY   r   r   r  r  r  r  r  )r\  rj  rp  r   r   rb  funcr  r   r   r    test_digitize_raise_if_x_complex  s   

z0TestNPFunctions.test_digitize_raise_if_x_complexc                    s`   t tdd  fddfdd}td}t|dks$J j| || d S )	NTr  c                     s:   |  \}} |  \}} || j ||ddd d S )Nr`  r~  ra  r  rJ  )r[   ZpyhistZpybinsZchistZcbinsrh  r   r   rv    s   z-TestNPFunctions.test_histogram.<locals>.checkc                    sJ   t g d} | |  | d|  | d  | dd  |  d S )Nrm  r  r  )rw  g      +@)r   r  r  )r9   rS  )rv  r   r   check_values  s   

z4TestNPFunctions.test_histogram.<locals>.check_values)r   rj  r   rk  r  r  r  r  rl  g     @E@rx  ry  r  )r\   r   r   r  r  rZ  ro  )r\  r  r9   r   )rp  rv  rj  r\  r   test_histogram  s   
zTestNPFunctions.test_histogramc              	   C   sd  t dd|}d}tjtjtjtjtjtjtjg}g d}t	
|||||D ]I\}}}}	}
tj||d}tj|	|d}t|tjrK|d|  |}t|tjr[|d|  |}||||
d}||||
d}| || q&tdd	d
}td}||f||ffD ])\}}| t}||| W d    n1 sw   Y  d}| |t|j qd S )NTr  )r   r~  r  r  )r   r   Zsamer   r  r   r  r  r  zonly supported on 1D arrays)r   r   r6  int32int64rg  r  rh  r  rc  r   r  
issubdtypeZcomplexfloatingr5  ri  r  r  r   r  r  r  )r\  rj  rp  lengthsdtsmodesZdt1Zdt2rC   r   r   r*   rP   rr  rq  _a_br   r   r  rb  r   r   r   _test_correlate_convolve  s6   

z(TestNPFunctions._test_correlate_convolvec                 C      |  t d S r   )r  r   r[  r   r   r   test_correlate  r2   zTestNPFunctions.test_correlatec              	   C   s   |    tjdd}td}tdd|}||f||ffD ]7\}}| t}||| W d    n1 s7w   Y  t|dkrL| dt	|j
 q| dt	|j
 q| t}|||d	d
 | dt	|j
 W d    d S 1 sww   Y  d S )Nr   )r  r|  Tr  r   z'a' cannot be emptyz'v' cannot be emptyzinvalid moder   zInvalid 'mode')r  r   r  r  r   r  r  r  r  r  r  )r\  rs  r  r  rp  r   r   r  r   r   r   #_test_correlate_convolve_exceptions  s   
"z3TestNPFunctions._test_correlate_convolve_exceptionsc                 C   r  r   )r  r   r[  r   r   r   test_correlate_exceptions     z)TestNPFunctions.test_correlate_exceptionsc                 C   r  r   )r  r   r[  r   r   r   test_convolve  r2   zTestNPFunctions.test_convolvec                 C   r  r   )r  r   r[  r   r   r   test_convolve_exceptions  r2   z(TestNPFunctions.test_convolve_exceptionsc                 C   s0   |di |}|di |}| j |||d d S )Nrd  r   rJ  )r\  rj  rp  paramsrd  rr  rq  r   r   r   _check_output  s   zTestNPFunctions._check_outputc                    s$  t }tdd|}t| j||  fdd}|tg d |tdd  |tdd	d
 |tdtjtj	tj	 g |tg  |tdd
d  |tdgd
 dgd   tj
tjtjtjfD ]}|tjd	|d qj|g d |d |d |d |d |d d S )NTr  c                    s   g d}ddg}d| i} | |D ]}| |d} | q|D ]}| |d} | q |D ]}|D ]}| ||d} | q2q.d S )N)Nr   r   r~  r  r  TFr   )r   r   )r   r   r   r   )r   Z	n_choicesZincreasing_choicesr  rC   r   r  r   r   _check'  s    




z1TestNPFunctions.test_vander_basic.<locals>._check)r   r~  r  r|  r        %@r  r  r|  333333?r}  333333?Fr  r   r   r   r~  r  r  r|  r  r  )r1  rw  rO  r   )r  g-@A`"	@)TFr  )r   r   r   r  r   r  r  r|  r4  r  r  r  rg  r  )r\  rj  rp  r  r   r   r  r   test_vander_basic"  s&   z!TestNPFunctions.test_vander_basicc                    s   t }tdd|   tdd  fdd}ddtjdd	gfD ]}|| q%t} d
d W d    n1 sBw   Y  dt	|j
  fdd}tdd| d| d S )NTr  r|  rz  c                    sJ     } | d W d    n1 sw   Y  dt|j d S )Nr   z,Second argument N must be None or an integerr  r  r  r  )r   r  rp  r\  r   r   r   _check_n`  s   
z8TestNPFunctions.test_vander_exceptions.<locals>._check_nr&  r   r~  r  r   z#Negative dimensions are not allowedc                    H    t} |  W d    n1 sw   Y  dt|j d S )Nz.x must be a one-dimensional array or sequence.)r  r  r  r  r  )r   r  rp  r\  r   r   	_check_1dn  s   
z9TestNPFunctions.test_vander_exceptions.<locals>._check_1dr  )r  r  r  )r~  r  rN  )r   r   r  r   r  r  r  r  r  r  r  r  )r\  rj  r  r   r  r  r   r  r   test_vander_exceptionsW  s$   
z&TestNPFunctions.test_vander_exceptionsc                 C   sH   t }tdd|}t| j||}dd }| D ]
}d|i}|| qd S )NTr  c                   S      t ddS Nr  r   r  r   r   r   r   n_variations  r'   z6TestNPFunctions.test_tri_n_basic.<locals>.n_variationsr   )r   r   r   r  )r\  rj  rp  r  r  rC   r  r   r   r   test_tri_n_basicz  s   

z TestNPFunctions.test_tri_n_basicc           	      C   z   t }tdd|}t| j||}dd }dd }| D ]
}d|i}|| q| D ]}| D ]}||d}|| q.q)d S )	NTr  c                   S   r  r  r  r   r   r   r   r    r'   z8TestNPFunctions.test_tri_n_m_basic.<locals>.n_variationsc                   S      t jd gtddfS Nr}  r  rc  chainfrom_iterablerZ  r   r   r   r   m_variations     z8TestNPFunctions.test_tri_n_m_basic.<locals>.m_variationsr   r   )r   r   r   r  )	r\  rj  rp  r  r  r  rC   r  r   r   r   r   test_tri_n_m_basic  s   





z"TestNPFunctions.test_tri_n_m_basicc           	      C   r  )	NTr  c                   S   r  r  r  r   r   r   r   r    r'   z8TestNPFunctions.test_tri_n_k_basic.<locals>.n_variationsc                   S   r  Nr  r  r   r   r   r   k_variations  r'   z8TestNPFunctions.test_tri_n_k_basic.<locals>.k_variationsr   r   )r   r   r   r  )	r\  rj  rp  r  r  r  rC   r  r   r   r   r   test_tri_n_k_basic  s   





z"TestNPFunctions.test_tri_n_k_basicc                 C   s   t }tdd|}t| j||}dd }dd }dd }| D ]
}d	|i}|| q| D ]}| D ]}	||	d
}|| q2q-| D ]}| D ]}
||
d}|| qGqB| D ]}| D ]}
| D ]}	||	|
d}|| qaq\qWd S )NTr  c                   S   r  r  r  r   r   r   r   r    r'   z:TestNPFunctions.test_tri_n_m_k_basic.<locals>.n_variationsc                   S   r  r  r  r   r   r   r   r    r  z:TestNPFunctions.test_tri_n_m_k_basic.<locals>.m_variationsc                   S   r  r  r  r   r   r   r   r    r'   z:TestNPFunctions.test_tri_n_m_k_basic.<locals>.k_variationsr   r   r   r   )r   r   r   r  )r\  rj  rp  r  r  r  r  rC   r  r   r   r   r   r   test_tri_n_m_k_basic  s6   













z$TestNPFunctions.test_tri_n_m_k_basicc                    sL   t }tdd|    fdd}ddtjddgfD ]}|| qd S )NTr  c                    sL     } dd| d W d    n1 sw   Y  dt|jv s$J d S )Nr|  r  r   k must be an integer)r  r  r  )r   r  r  r   r   r    s   
z3TestNPFunctions.test_tri_exceptions.<locals>._checkrn  r   r~  )r   r   r  r   r  )r\  rj  r  r   r   r  r   test_tri_exceptions  s   
z#TestNPFunctions.test_tri_exceptionsc                    ,   t dd  fdd}|S )NTr  c                    s2   | } | } |j|j tj|| d S r   )r  r   r   testingassert_array_equal)r8   rr  rq  rh  r   r   r    s   z:TestNPFunctions._triangular_matrix_tests_m.<locals>._checkr   _triangular_matrix_tests_innerr\  rj  r  r   rh  r   _triangular_matrix_tests_m  s   z*TestNPFunctions._triangular_matrix_tests_mc                    r  )NTr  c                    sv   t jd gtddfD ],}|d u ri }nd|i}| fi |} | fi |}|j|j tj|| qd S )Nr  r  r   )	rc  r  r  rZ  r  r   r   r  r  )r8   r   r  rr  rq  rh  r   r   r    s   z<TestNPFunctions._triangular_matrix_tests_m_k.<locals>._checkr  r  r   rh  r   _triangular_matrix_tests_m_k  s   z,TestNPFunctions._triangular_matrix_tests_m_kc                    s    fdd} fdd}|t dd  |t dd   t dd	d
dd  t g   t ddd d d   t djddd t dd d} |  t | d S )Nc                    :    |  |  d}  |  |  d}  |   | j d S )N)r  r  )r  r   r  r  r  TrA   r  r   r   	check_odd
     

zATestNPFunctions._triangular_matrix_tests_inner.<locals>.check_oddc                    r  )N)r     r  r~  r~  r  r  rA   r  r   r   
check_even  r  zBTestNPFunctions._triangular_matrix_tests_inner.<locals>.check_even?   r  @   ih  r  r  r|  r  r  )r  r  r  Forderr  )r   r  r  r  asfortranarray)r\  rj  r  r  r  r8   r   r  r   r    s   z.TestNPFunctions._triangular_matrix_tests_innerc                 C   sl   t dd|}|   td}|  }||dd | dt|j W d    d S 1 s/w   Y  d S )NTr  r|  r  rn  r  r  )r   r  r   r  r  r  r  r  )r\  rj  rp  r*   r  r   r   r   _triangular_matrix_exceptions'  s   

"z-TestNPFunctions._triangular_matrix_exceptionsc           	      C   sv   t dd|}|D ]/}|| }|| }| t|t| | t|t| t||D ]\}}tj|| q,q	d S r8  )r   r  typer  re  r   r  r  )	r\  rj  r[   rp  r   rr  rq  egr   r   r   _triangular_indices_tests_base2  s   z.TestNPFunctions._triangular_indices_tests_basec                 C      |  |dd tdD  d S )Nc                 S   s   g | ]}|gqS r   r   )r  rC   r   r   r   r  @  s    z?TestNPFunctions._triangular_indices_tests_n.<locals>.<listcomp>r  r  rZ  r\  rj  r   r   r   _triangular_indices_tests_n=     z+TestNPFunctions._triangular_indices_tests_nc                 C   r  )Nc                 S   s.   g | ]}t | d  |d D ]}||gqqS r   r~  rZ  )r  rC   r   r   r   r   r  F  s   . zATestNPFunctions._triangular_indices_tests_n_k.<locals>.<listcomp>r  r  r  r   r   r   _triangular_indices_tests_n_kC  r  z-TestNPFunctions._triangular_indices_tests_n_kc                 C   r  )Nc                 S   s&   g | ]}t d | D ]}||gq
qS r=  r  )r  rC   r   r   r   r   r  L  s   & zATestNPFunctions._triangular_indices_tests_n_m.<locals>.<listcomp>r  r  r  r   r   r   _triangular_indices_tests_n_mI  r  z-TestNPFunctions._triangular_indices_tests_n_mc                 C   s4   |  |dd tdD  tdd|}|d d S )Nc                 S   sB   g | ]}t | d  |d D ]}t d| D ]}|||gqqqS r  r  )r  rC   r   r   r   r   r   r  R  s    
zCTestNPFunctions._triangular_indices_tests_n_k_m.<locals>.<listcomp>r  Tr  r   )r  rZ  r   )r\  rj  rp  r   r   r   _triangular_indices_tests_n_k_mO  s   z/TestNPFunctions._triangular_indices_tests_n_k_mc                 C   s   t dd|}tttfD ]F}ttdtdD ]9\}}t||f|}||}||}| 	t
|t
| | 	t|t| t||D ]\}	}
tj|	|
 qEqqd S )NTr  r  r   r  rR  boolrc  r   rZ  r   r  r  r  r  re  r  r  )r\  rj  rp  r   rC   r   r8   rr  rq  r  r  r   r   r   "_triangular_indices_from_tests_arr[  s   z2TestNPFunctions._triangular_indices_from_tests_arrc                 C   s   t dd|}tttfD ]N}ttdtdD ]A\}}t||f|}tddD ]/}||}||}	| 	t
|t
|	 | 	t|t|	 t||	D ]\}
}tj|
| qLq)qqd S )NTr  r  r  r  )r\  rj  rp  r   rC   r   r8   r   rr  rq  r  r  r   r   r   $_triangular_indices_from_tests_arr_kh  s   z4TestNPFunctions._triangular_indices_from_tests_arr_kc                 C   s   t dd|}t|j}|  }|d W d    n1 sw   Y  | dt|j d|v rT|  }|ddd W d    n1 sFw   Y  | dt|j d	|v r}|  }|ddd
 W d    n1 smw   Y  | dt|j d S d S )NTr  rw  zn must be an integerr   r   r  r  r   r   zm must be an integer)r   r   
parametersr  r  r  r  )r\  rj  rp  r  r  r   r   r   _triangular_indices_exceptionsv  s"   




z.TestNPFunctions._triangular_indices_exceptionsTc              	   C   s   t dd|}dD ]+}tdg| }|  }|| W d    n1 s&w   Y  | dt|j q	|rctddg}|  }||dd W d    n1 sSw   Y  | dt|j d S d S )	NTr  r   r   r  r|  zinput array must be 2-drz  r  r  )r   r   r  r  r  r  r  )r\  rj  Ztest_krp  Zndimsr*   r  r   r   r   #_triangular_indices_from_exceptions  s   


z3TestNPFunctions._triangular_indices_from_exceptionsc                 C      |  t | t d S r   )r  r   r  r   r[  r   r   r   test_tril_basic     
zTestNPFunctions.test_tril_basicc                 C   r  r   )r  r   r[  r   r   r   test_tril_exceptions  r2   z$TestNPFunctions.test_tril_exceptionsc                 C   T   |  t | t | t | t | t | t | t | t d S r   )	r  r   r  r   r  r   r  r   r  r[  r   r   r   test_tril_indices     






z!TestNPFunctions.test_tril_indicesc                 C   0   |  t | t | td | td d S NFT)r  r   r  r   r  r[  r   r   r   test_tril_indices_from     

z&TestNPFunctions.test_tril_indices_fromc                 C   r  r   )r  r   r  r   r[  r   r   r   test_triu_basic  r  zTestNPFunctions.test_triu_basicc                 C   r  r   )r  r   r[  r   r   r   test_triu_exceptions  r2   z$TestNPFunctions.test_triu_exceptionsc                 C   r  r   )	r  r   r  r   r  r   r  r   r  r[  r   r   r   test_triu_indices  r  z!TestNPFunctions.test_triu_indicesc                 C   r  r  )r  r   r  r   r  r[  r   r   r   test_triu_indices_from  r  z&TestNPFunctions.test_triu_indices_fromc                 C   s8   t }tt }dd }| D ]}| |||| qd S )Nc                   s   s    dV  dV  dV  dV  d S )N)r  r  )r  r  )r~  r~  r  r|  r   r   r   r   r   inputs  s
   
z2TestNPFunctions.test_indices_basic.<locals>.inputs)r8  r   ri  )r\  rj  rp  r   dimsr   r   r   test_indices_basic  s   
z"TestNPFunctions.test_indices_basicc                 C   s   t t}|   d}| t}|d W d    n1 sw   Y  | |t|j | t}|d W d    n1 s@w   Y  | |t|j | t}|d W d    n1 sbw   Y  | |t|j d S )Nz5The argument "dimensions" must be a tuple of integersabc)rO  r  )r~  r  )r   r8  r  r  r   r  r  r  )r\  rp  errmsgr  r   r   r   test_indices_exception  s*   


z&TestNPFunctions.test_indices_exceptionc                 C   sh   |||}|||}|  t|d | t|d |  |  t||d  t||d   d S r   ri  r   r  r\  rj  rp  r*   r   rr  rq  r   r   r   partition_sanity_check  s   

(,z&TestNPFunctions.partition_sanity_checkc              	   C   sx   |||}|||}|  t||d |  t||d |   |  t|||d   t|||d    d S r   r  r  r   r   r   argpartition_sanity_check  s   

z)TestNPFunctions.argpartition_sanity_checkc           
   	   C   s   t }tdd|}tddD ]n}td|d D ]d}t|}| j| || jdd }| j|j}d|||d | | g}t	|| }| 
|||| | | 
|| || | | 
|t| || | |D ]
}	| ||||	 qpqqd S NTr  r  r  r   r~  r   )r   r   rZ  r   r  rZ  ro  r  r  r\  ri  tolisttupler  
r\  rj  rp  jr^  didxr   tgtr   r   r   r   test_partition_fuzz	  s0   
z#TestNPFunctions.test_partition_fuzzc           
   	   C   s  t }tdd|}tddD ]z}td|d D ]p}t|}| j| || jdd }| j|j}d|||d | | g}t	|| }| 
|||||  ||  | 
||| ||  ||  | 
||t| ||  ||  |D ]
}	| ||||	 q|qqd S r
  )r   r   rZ  r   r  rZ  ro  r  r  argsortri  r  r  r	  r  r   r   r   test_argpartition_fuzz	  s0   
z&TestNPFunctions.test_argpartition_fuzzc                    T   t }tdd|   td} fdd}||d ||d ||d d S )NTr  r  c                    J    t} | | W d    n1 sw   Y  t|jdks#J d S Nzkth out of boundsr  r  r  r  r*   r   r  r  r   r   r  @	     zETestNPFunctions.test_partition_exception_out_of_range.<locals>._checkr  r  )r   r   r  r   r  r\  rj  r*   r  r   r  r   %test_partition_exception_out_of_range4	     


z5TestNPFunctions.test_partition_exception_out_of_rangec                    r  )NTr  r  c                    r  r  r  r  r  r   r   r  U	  r  zHTestNPFunctions.test_argpartition_exception_out_of_range.<locals>._checkr  r  )r   r   r  r   r  r  r   r  r   (test_argpartition_exception_out_of_rangeI	  r  z8TestNPFunctions.test_argpartition_exception_out_of_rangec                    b   t }tdd|    fdd}td}||d ||d ||tdd	tjf d S )
NTr  c                    H     } | | W d    n1 sw   Y  dt|j d S NzPartition index must be integerr  r*   r   r  r  r   r   r  g	     
zHTestNPFunctions.test_partition_exception_non_integer_kth.<locals>._checkr        "@ffffff
@rk  r   r~  )r   r   r  r   r  r  r4  r\  rj  r  r*   r   r  r   (test_partition_exception_non_integer_kth^	     


z8TestNPFunctions.test_partition_exception_non_integer_kthc                    r!  )
NTr  c                    r"  r#  r  r$  r  r   r   r  {	  r%  zKTestNPFunctions.test_argpartition_exception_non_integer_kth.<locals>._checkr  r&  r'  r   r~  )r   r   r  r   r  r  r4  r)  r   r  r   +test_argpartition_exception_non_integer_kthr	  r+  z;TestNPFunctions.test_argpartition_exception_non_integer_kthc                    @   t }tdd|    fdd}|dd |dd d S )NTr  c                    r"  Nz(The first argument must be an array-liker  r$  r  r   r   r  	  r%  zITestNPFunctions.test_partition_exception_a_not_array_like.<locals>._checkr  r   Sausages)r   r   r  r  r   r  r   )test_partition_exception_a_not_array_like	     
z9TestNPFunctions.test_partition_exception_a_not_array_likec                    r-  )NTr  c                    r"  r.  r  r$  r  r   r   r  	  r%  zLTestNPFunctions.test_argpartition_exception_a_not_array_like.<locals>._checkr  r   r/  )r   r   r  r  r   r  r   ,test_argpartition_exception_a_not_array_like	  r1  z<TestNPFunctions.test_argpartition_exception_a_not_array_likec                    <   t }tdd|    fdd}|tdd d S )NTr  c                    r"  Nz3The first argument must be at least 1-D (found 0-D)r  r$  r  r   r   r  	  r%  zCTestNPFunctions.test_partition_exception_a_zero_dim.<locals>._checkr   r   )r   r   r  r   r  r  r   r  r   #test_partition_exception_a_zero_dim	  
   z3TestNPFunctions.test_partition_exception_a_zero_dimc                    r3  )NTr  c                    r"  r4  r  r$  r  r   r   r  	  r%  zFTestNPFunctions.test_argpartition_exception_a_zero_dim.<locals>._checkr   r   )r   r   r  r   r  r  r   r  r   &test_argpartition_exception_a_zero_dim	  r6  z6TestNPFunctions.test_argpartition_exception_a_zero_dimc                    L   t }tdd|    fdd}|tdtdddd	 d S )
NTr  c                    J    t} | | W d    n1 sw   Y  dt|j d S Nzkth must be scalar or 1-Drr  r$  r  r   r   r  	  r  zNTestNPFunctions.test_partition_exception_kth_multi_dimensional.<locals>._checkr  r  r  r~  r   )r   r   r  r   r  r  r  r   r  r   .test_partition_exception_kth_multi_dimensional	  
   $z>TestNPFunctions.test_partition_exception_kth_multi_dimensionalc                    r8  )
NTr  c                    r9  r:  rr  r$  r  r   r   r  	  r  zQTestNPFunctions.test_argpartition_exception_kth_multi_dimensional.<locals>._checkr  r  r  r~  r;  )r   r   r  r   r  r  r  r   r  r   1test_argpartition_exception_kth_multi_dimensional	  r=  zATestNPFunctions.test_argpartition_exception_kth_multi_dimensionalc                    V   t tdd d fdd	}tg }d|_|dtg fD ]}|| q"d S )	NTr  r   c                    $   | |} | |} || d S r   rJ  r*   r   rr  rq  rh  r   r   rv  	     

z9TestNPFunctions.test_partition_empty_array.<locals>.checkr  r~  r   r   r   r  )r   r   r   r  r  r\  rv  r*   r8   r   rh  r   test_partition_empty_array	     

z*TestNPFunctions.test_partition_empty_arrayc                    r?  )	NTr  r   c                    r@  r   rJ  rA  rh  r   r   rv  	  rB  z<TestNPFunctions.test_argpartition_empty_array.<locals>.checkrC  r   r  )r   r   r   r  r  rD  r   rh  r   test_argpartition_empty_array	  rF  z-TestNPFunctions.test_argpartition_empty_arrayc              	   C   s  t }tdd|}tg }||d}| || td}||d}| || tg d}| }|td| | || ddgddgddgfD ]&}t|}t|}dD ]}	| |||	|	 ||	  | 	||||	 q[qMg d	g d
g dg dg dg dg dg dfD ]&}t|}t|}dD ]}	| |||	|	 ||	  | 	||||	 qqtd}| ||d| td}dD ]}	| 
|||	|	 |	 | 	||||	 qtdd d d }|| t| fD ]8}
| 
||
dd d | 
||
dd d | ||
d||
d | ||
d||
d | 	|||d qtd}t||jd }|jd d }| 
|||| | td}t||jd d }|jd d }| 
|||| | td}d |d< | 
||d!d d  | 
||d!d d tj|d< t||d!d sJ tdd" }ttdd" }| j| t|jD ]}| 
|||| ||  | 	|||| qtg d#}g d$}| 
t|||| d% d&d' tjtjfD }|D ]^\}}tj||d(}| j| ttj||d(d)}t| jj| t|jD ]4}|||}| 
|| | tj|d | ||  tj|| ||d d   | 	|||| q#qd S )*NTr  r   r   r  r  r|  (   r~  r   r   r  r~  r   r  r~  r   r  r~  r  r   r   r   r   r  r~  r~  r   r   r~  r   r   r   r~  r   1   r|  r  /   r  r  r  ry  )      @B AB r  r  r~  r  r  r   r   r~  r  r  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r     r  r   r  r  r  c                 S      g | ]}d D ]}||fqqS )r  r  r   r  dtsr   r   r   r  [
      z8TestNPFunctions.test_partition_basic.<locals>.<listcomp>r   r  r   )r   r   r   r  ri  r  r3  r  r\  r  r  r  r  r   r  r4  isnanrZ  ro  rZ  r  rg  tilemapr  assert_array_less)r\  rj  rp  r  rq  r   okthr  r  r   r*   r   midr^  tdrb  rc  d1r&  r   r   r   test_partition_basic
  s   














z$TestNPFunctions.test_partition_basicc              	   C   s  t }tdd|}tjg tjd}||d}||d}| || tjdtjd}||d}||d}| || tg d}| }|td| | || ddgddgddgfD ]*}t|}t	|}	d	D ]}
| ||||
|
  ||	|
   | 
||||
 qkq]g d
g dg dg dg dg dg dg dfD ]*}t|}t	|}	dD ]}
| ||||
|
  ||	|
   | 
||||
 qqtd}| |||d | td}dD ]}
| |||
|
 |
 | ||||
 qtdd d d }|| t| fD ]9}| ||dd d | ||dd d | ||d||d | ||d||d | 
|||d qtd}t||jd }|jd d }| |||||  | td }t||jd d }|jd d }| |||||  | td!}d"|d< | |||d#d  d" | |||d#d  d tj|d< t|||d#d  sJ tdd$ }ttdd$ }	| j| t|jD ]}| |||||  |	|  | 
|||| qtg d%}g d&}| t|||||  d' d(d) tjtjfD }|D ]`\}}tj||d}| j| ttj||dd*}t| jj| t|jD ]6}|||| }| || | tj|d | ||  tj|| ||d d   | 
|||| qLq$d S )+NTr  r   r   r   rH  rI  r~  rJ  rK  r  rL  rM  rN  r  rO  rP  rQ  r   rR  rS  rT  r  r  r  r  ry  rU  rV  rW  rX  rY  r  r  rZ  r  r[  r\  r^  c                 S   r_  r`  r   ra  r   r   r   r  
  rd  z;TestNPFunctions.test_argpartition_basic.<locals>.<listcomp>re  )r   r   r   r  r  ri  r  r3  r  r  r	  r  r  r  r  r   r  r4  rf  r\  rZ  ro  rZ  r  rg  rg  rh  r  ri  )r\  rj  rp  r  rr  rq  r   rj  r  r  r   r*   r   rk  r^  rl  rb  rc  rm  r&  r   r   r   test_argpartition_basick
  s   





"

"





z'TestNPFunctions.test_argpartition_basicc                 C      d}t |D ];}t jj||| || d| d | j||d  || k d|||d  || f d |d }| |||| qd S Nr   zkth %d)err_msgzkth %d, %r not greater equal %drb  r   )r   r\  r  ri  r,  allr  r\  rj  rp  r  r   prevr   r   r   r   assert_partitioned
     z"TestNPFunctions.assert_partitionedc                 C   rp  rq  )r   r\  r  ri  r,  rt  r	  ru  r   r   r   assert_argpartitioned
  rx  z%TestNPFunctions.assert_argpartitionedc                 C   s`  t }tdd|}t| j||}tg d}||d}||d ||t|d d | |||d td}| j	
| | td||tt|j td}| j	
| tg d}| j	
| |||}||| | j	
| | |||| tdd d d	 }|||d
gd d
g |||d
gd ddg d
gd ddg  d S NTr  )r  r  r~  r   )r   r  )r  r  rF  )r   r  r  r  r  r  r|  r  r  r  )r   r   r   rw  r   r  r   ri  r  rZ  ro  r  rZ  r  )r\  rj  rp  rw  r  r&  keysr   r   r   test_partition_iterative
  s,   


"


0z(TestNPFunctions.test_partition_iterativec              	   C   s|  t }tdd|}t| j||}tg d}|||d }||d ||t |d d | ||||d  td}| j	| | td|||t
t|j  td}| j	| tg d}| j	| |||| }||| | j	| | |||| | tdd d d	 }||||d
gd  d
g ||||d
gd ddg  d
gd ddg  d S rz  )r   r   r   ry  r   r  ri  r  rZ  ro  r  rZ  r  )r\  rj  rp  ry  r  r&  r{  r   r   r   test_argpartition_iterative
  s2   

&

4z+TestNPFunctions.test_argpartition_iterativec                       t tdd  fdd}dd }tddd	}tj|d
d< tj |d< tj|d< |d}||D ]}tddD ]}||| q>q7d S )NTr  c              	      s   | |} | |} |d d d d |f |d d d d |f  t|jd d D ]2} t|| d | t|| d |   t|| |d  t|| |d   q,d S Nr  )ri  r   ndindexr  r  )r*   r   rr  rq  rc  rh  r   r   rv  2  s   

0z7TestNPFunctions.test_partition_multi_dim.<locals>.checkc                 s   Z    | V  | j V  t| V  tj| tjdV  tj| tjdV  ddtj dfffV  d S NrU  rw  r  r  r  r   r  Z	full_liker4  r  rA   r   r   r   a_variations=     z>TestNPFunctions.test_partition_multi_dim.<locals>.a_variationsr   r  0   r  r  r  r  r  r  r  r  r  )r   r   r   r|  r4  r  r  rZ  r\  rv  r  r*   r8   r   r   rh  r   test_partition_multi_dim.  s   	

z(TestNPFunctions.test_partition_multi_dimc                    r~  )NTr  c              
      s  | |} | |}t | } t | jd d }|D ]}| | || |  | | || |   qt |jd d D ]B}t | | || d |  t | | || d |   t | | || |d   t | | || |d    q>d S r  )r   r   r  r  ri  r  )r*   r   rr  rq  r  rc  rh  r   r   rv  T  s    


  z:TestNPFunctions.test_argpartition_multi_dim.<locals>.checkc                 s   r  r  r  rA   r   r   r   r  c  r  zATestNPFunctions.test_argpartition_multi_dim.<locals>.a_variationsr   r  r  r  r  r  r  r  r  r  )r   r   r   r|  r4  r  r  rZ  r  r   rh  r   test_argpartition_multi_dimP  s   	

z+TestNPFunctions.test_argpartition_multi_dimc                 C   N   t }tdd|}tdddtdfD ]}dD ]
}| |||| qqd S NTr  r   r  rF  TFT)TFr  r   r   )r   r   r   r|  r  r  r\  rj  rp  r  r   r   r   r   test_partition_boolean_inputsv     z-TestNPFunctions.test_partition_boolean_inputsc                 C   r  r  )r   r   r   r|  r  r	  r  r   r   r    test_argpartition_boolean_inputs~  r  z0TestNPFunctions.test_argpartition_boolean_inputsc              	   C   sB  t }tdd|}|   tddgddgddggj}tddfD ]%}|  }|||d W d    n1 s:w   Y  | d	t	|j
 q#tjtjfD ]&}| t}|||d W d    n1 sgw   Y  | d
t	|j
 qOdD ]&}| t}|||d W d    n1 sw   Y  | dt	|j
 qxd S )NTr  r   r~  r   r                @)r   z)ddof must be a real numerical scalar typez)Cannot convert non-finite ddof to integer)r&  gffffffzddof must be integral value)r   r   r  r   r  r  r  r  r  r  r  r4  r  r  r  )r\  rj  rp  r   r   r  r   r   r   test_cov_invalid_ddof  s0   
z%TestNPFunctions.test_cov_invalid_ddofc                    sH   t dd|}t j||dd} fdd}| D ]}|||i qd S )NTr  +=r  c                   3   sV   t ddgddgddggjV   jdddV  t t ddgddgddggjV   jdddd d d d df V  t g dV  t jdd	d
V  t t jdt j	 ddgV  t 
dddddV  dV  dV  dV  dV  g dV  dV  ddgV  dV  dV  t g V  t g ddV  t g ddV  dV  d S )Nr   r~  r   r  r|  r  )g&S:?o_?g#~j?甇ZӼ?Q|?rN  TrU  r  r  r  r  r  !   )皙?皙?g)\(?gRQ?)g
ףp=
?gzG?)r  r  )y        
ףp=
?y        zG?g r  g333333@r  r  )r  r  r  r  )r   r  r~  r  ))r&  皙@rn  r   )r   r  r  rZ  randnr  r  r   r4  r  r|  r   r[  r   r   input_variations  s,    &(


z=TestNPFunctions.corr_corrcoef_basic.<locals>.input_variations)r   r   r  )r\  rj  first_arg_namerp  r  r  Z	input_arrr   r[  r   corr_corrcoef_basic  s   
z#TestNPFunctions.corr_corrcoef_basicc                 C      t }| j|dd d S )Nr   r  )r   r  r  r   r   r   test_corrcoef_basic     z#TestNPFunctions.test_corrcoef_basicc                 C   r  )Nr   r  )r   r  r  r   r   r   test_cov_basic  r  zTestNPFunctions.test_cov_basicc                 C   s   t }tdd|}t| j||dd}| jddd}d |d d d f}d	}d	}d
}t||||}	|	D ]\}
}}}||
|||d}|| q5d S )NTr  r  r  i   r  r  r  FT)Nr  r   r   r  T)r   r   r   r   r   )	r   r   r   r  rZ  r  r  rc  r   )r\  rj  rp  r  r   	y_choicesrowvar_choicesZbias_choicesZddof_choiceZproductsr   r   r   r   r  r   r   r   test_cov_explicit_arguments  s"   
z+TestNPFunctions.test_cov_explicit_argumentsc           
      C   s|   t }tdd|}t| j||dd}| jddd}d |d d d f}d	}t||D ]\}}|||d
}	||	 q-d S )NTr  r  r  r  r  r  r  r  r   )	r   r   r   r  rZ  r  r  rc  r   )
r\  rj  rp  r  r   r  r  r   r   r  r   r   r    test_corrcoef_explicit_arguments  s   
z0TestNPFunctions.test_corrcoef_explicit_argumentsc           	      C   s  t dd|}t| j||dd}tg d}tg d}||d|i}|| tg d}tg d	g}||d|i}|| tg d}d	}||d|i}|| ||d|i}|| tg d}d
}||d|i}|| ||d|i}|| tg }tg }||d|i}|| d}d}||d|i}|| | jdd}tg dddd }||d|i}|| tg d}tg dg dg}||d|i}|| dD ]/}tg d}tg dg dg dg}||d|d|i}|| ||d|d|i}|| qd S )NTr  r  r  r  )r  r&  Q?r   r  r  r  r  )r  r  r  r&  r  r  r  r   r  )r  r&  r  r   )r   r   r  r   r  rZ  r  r  )	r\  rj  r  rp  r  r   r   r  r   r   r   r   cov_corrcoef_edge_cases  s\   


z'TestNPFunctions.cov_corrcoef_edge_casesc                 C   s^   t }| j|dd tdd|}t| j||dd}tjtj ddfD ]
}d|i}|| q"d S )	Nr   r  Tr  r  r  r  r   )r   r  r   r   r  r   r4  r  r\  rj  rp  r  r   r  r   r   r   test_corrcoef_edge_cases-  s   
z(TestNPFunctions.test_corrcoef_edge_casesc                 C   s<   t }tdd|}t| j||dd}d}d|i}|| d S )NTr  r  r  ))r$  }Ô%IT)r  r$  r   )r   r   r   r  r  r   r   r   &test_corrcoef_edge_case_extreme_values9  s   z6TestNPFunctions.test_corrcoef_edge_case_extreme_valuesc                 C   sf   t }| j|dd tdd|}t| j||dd}tddgd	d	gddggj}|d
d}|| d S )Nr   r  Tr  r  r  r   r~  r   r|  )r   r   )r   r  r   r   r  r   r  r  )r\  rj  rp  r  r   r  r   r   r   test_cov_edge_casesD  s   
z#TestNPFunctions.test_cov_edge_casesc                    sX  t }tdd|    fdd}td}|| d}|| g dgg}||  fdd}td	}td}||| td
}d}||| td}td}t} ||d W d    n1 sow   Y  	dt
|j tg ddd}t} | W d    n1 sw   Y  	dt
|j d S )NTr  c                    sF     } |  W d    n1 sw   Y  dt|j d S )Nzm has more than 2 dimensionsr  )r   r  r  r   r   _check_mY  s   

z5TestNPFunctions.test_cov_exceptions.<locals>._check_mr|  r  r  )))r  r  c                    sJ     } | |d W d    n1 sw   Y  dt|j d S )Nr   zy has more than 2 dimensionsr  )r   r   r  r  r   r   _check_yg  s   
z5TestNPFunctions.test_cov_exceptions.<locals>._check_yr  )r&  r  r&  )))r  r  ru  r  r  r   z$m and y have incompatible dimensionsr  r   z/2D array containing a single row is unsupported)r   r   r  r   r  r  r  r  r  r  r  r  r  RuntimeError)r\  rj  r  r   r  r   r  r   r  r   test_cov_exceptionsQ  s@   








z#TestNPFunctions.test_cov_exceptionsc           
      C   s   t }tdd|}t| j||}dd }dd }|tddd	D ]4}d
|i}|| ||D ]%}||d}|| ||d}|| ||D ]}	|||	d}|| qGq/q!d S )NTr  c                 s   s     d V  | V  |  tjV  d S r   )r5  r   r  rA   r   r   r   to_variations  s   z9TestNPFunctions.test_ediff1d_basic.<locals>.to_variationsc                 s   s*    | V  |  dddV  | tjV  d S )Nr  r~  )r  r5  r   r  rA   r   r   r   ary_variations  s   z:TestNPFunctions.test_ediff1d_basic.<locals>.ary_variationsr  r  r  r   )r   r   )r   r   )r   r   r   )r   r   r   r  r   r|  )
r\  rj  rp  r  r  r  r   r  r*   r+   r   r   r   test_ediff1d_basic  s&   


z"TestNPFunctions.test_ediff1d_basicc                 C   sj   t }tdd|}|   |  }|td W d    n1 s#w   Y  d}|t|jv s3J d S )NTr  )TTFz+Boolean dtype is unsupported (as per NumPy))r   r   r  r  r   r  r  r  )r\  rj  rp  r  rb  r   r   r   test_ediff1d_exceptions  s   
z'TestNPFunctions.test_ediff1d_exceptionsc                 C      t }tdd|}dd }| D ]}||}||}| || q| t}|d W d    n1 s5w   Y  | dtj t|j	 d S )NTr  c                   s   sH    t dddV  t ddddV  dV  ddgddgfV  d S )	Nr  r|  r~  r  r  r   r  r  r  r   r   r   r   r    s
   z7TestNPFunctions.test_fliplr_basic.<locals>.a_variationsr  zCannot np.fliplr on %s type)
rv   r   ri  r  r   r  r   unicode_typer  r  r\  rj  rp  r  r*   rr  rq  r  r   r   r   test_fliplr_basic  s   

z!TestNPFunctions.test_fliplr_basicc                 C   sz   t }tdd|}|   | t}|td W d    n1 s$w   Y  | dt|j	 | dt|j	 d S )NTr  r  cannot index arrayzwith 2 indices)
rv   r   r  r  r   r   r  r  r  r  r  r   r   r   test_fliplr_exception  s   z%TestNPFunctions.test_fliplr_exceptionc                 C   r  )NTr  c                   s   s\    dgV  t dV  t dddV  t ddddV  dV  ddgddgfV  d S )	Nr   r  r|  r~  r  r  r  r  r  r   r   r   r   r    s   z7TestNPFunctions.test_flipud_basic.<locals>.a_variationsr  zCannot np.flipud on %s type)
rx   r   ri  r  r   r  r   r  r  r  r  r   r   r   test_flipud_basic  s   

z!TestNPFunctions.test_flipud_basicc                 C   st   t }tdd|}|   | t}|d W d    n1 s!w   Y  | dt|j | dt|j d S )NTr  r   r  zwith 1 indices)rx   r   r  r  r   r  r  r  r  r   r   r   test_flipud_exception  s   
z%TestNPFunctions.test_flipud_exceptionc                 C   s   t }tdd|}dd }| D ]}||}||}| || q| t}|d W d    n1 s5w   Y  | dt|j d S )NTr  c                   s   sH    t dV  t dV  t dddV  t ddddV  d S )Nr   r  r|  r~  r  r  r   r   r   r   r    s
   z5TestNPFunctions.test_flip_basic.<locals>.a_variationsr  zCannot np.flip on UniTuple)ry   r   ri  r  r   r  r  r  r  r   r   r   test_flip_basic  s   

zTestNPFunctions.test_flip_basicc                 C   H   dd }t }tdd|}| D ]\}}tj|||||| qd S )Nc                   s       dV  dV  dV  dV  dV  dV  dV  dV  d	t jfV  d	t jfV  td
k rmt dt dfV  t dt dfV  t dt dfV  t dt dfV  t dt dfV  t dt dfV  d S d S N)r   r  )r  r  )r  r  r  )r  r  rw        N@      Nrx  )rx  r  r1  r~  r   r   r~  r  r        ?       @      @      @      ?             @                   @r   r  pir   rh  r   r   r   r   r   
  &   z4TestNPFunctions.test_logspace2_basic.<locals>.inputsTr  )r~   r   r   r  assert_allcloser\  r   rj  rp  r|   r}   r   r   r   test_logspace2_basic     z$TestNPFunctions.test_logspace2_basicc                 C   s   t ddt}|   | t}|dd W d    n1 s w   Y  | dt|j | t}|dd W d    n1 sCw   Y  | dt|j d S )NTr  r  r|  +The first argument "start" must be a number+The second argument "stop" must be a number)r   r~   r  r  r   r  r  r  r\  rp  r  r   r   r   test_logspace2_exception$  s   z(TestNPFunctions.test_logspace2_exceptionc                 C   r  )Nc                   s   r  r  r  r   r   r   r   r   5  r  z4TestNPFunctions.test_logspace3_basic.<locals>.inputsTr  r   r   r   r  r  r  r   r   r   test_logspace3_basic3  r  z$TestNPFunctions.test_logspace3_basicc                 C   sN   dd }t }tdd|}| D ]\}}}tj|||||||| qd S )Nc                   s   s    dV  dV  dV  dV  dV  dV  dV  dV  d	t jd
fV  d	t jdfV  tdk rut dt ddfV  t dt ddfV  t dt ddfV  t dt ddfV  t dt ddfV  t dt ddfV  d S d S )N)r   r  r  )r  r  r  )r  r  rI  r  r  r   )r  r  r  rw  r  F   r  rx  P   )rx  r  Z   r1  r  r  r  r   r~  rI  r  r  r   r  r  r  r  r  r  r  r  r  r  r   r   r   r   r   Q  s&   z=TestNPFunctions.test_logspace3_with_num_basic.<locals>.inputsTr  r  r\  r   rj  rp  r|   r}   r   r   r   r   test_logspace3_with_num_basicO  s   
z-TestNPFunctions.test_logspace3_with_num_basicc                 C   s   t ddt}|   | t}|dd W d    n1 s w   Y  | dt|j | t}|dd W d    n1 sCw   Y  | dt|j | t}|ddd W d    n1 sgw   Y  | dt|j d S )	NTr  r  r|  r  r  r   z+The third argument "num" must be an integer)r   r   r  r  r   r  r  r  r  r   r   r   test_logspace3_exceptionl  s(   z(TestNPFunctions.test_logspace3_exceptionc                 C   sJ   dd }t }tdd|}| D ]\}}| j||||||dd qd S )Nc                   s   s   dV  dV  dV  dV  dV  dV  dV  dt d	fV  t d	dfV  d
t d	fV  t dt dfV  t dt dfV  t dt dfV  t d	t dfV  t dt dfV  t dt dfV  t dt dfV  t dt dfV  d S )Nr  r  r  )r   r  )r  r   )r      )r  r  r  rx  r               @@r  r  r   r~  r  r  r  r  r  r  r   rh  r   r   r   r   r     s&   z5TestNPFunctions.test_geomspace2_basic.<locals>.inputsTr  g-q=r  )r   r   ri  r  r   r   r   test_geomspace2_basic  s   z%TestNPFunctions.test_geomspace2_basicc                 C   s2  t ddt}|   | t}|dd W d    n1 s w   Y  | dt|j | t}|dd W d    n1 sCw   Y  | dt|j | t}|dd W d    n1 sfw   Y  | dt|j | t}|dd W d    n1 sw   Y  | dt|j d S )	NTr  r  r|  %The argument "start" must be a number$The argument "stop" must be a numberr   &Geometric sequence cannot include zero)	r   r   r  r  r   r  r  r  r  r  r   r   r   test_geomspace2_exception  s4   z)TestNPFunctions.test_geomspace2_exceptionc                 C   sP   dd }t }tdd|}| D ]\}}}| j||||||||dd qd S )Nc                   s   s,   dV  dV  dV  dV  dV  dV  dV  dV  d	t d
dfV  t d
d	dfV  dt d
dfV  t dt ddfV  t dt ddfV  t dt ddfV  t d
t ddfV  t dt ddfV  t dt ddfV  t dt dd fV  t d!t dd"fV  d S )#Nr  r  r  )r   r  r  )r   r  r  )r  r   r  )r   r  r  )r  r  r  r  r  r  r  rx  r  r  r  r  r  r  r|  r   r~  rI  r  r   r  r  r  r  r  r  r  r  r  r  r   r   r   r   r     s(   z5TestNPFunctions.test_geomspace3_basic.<locals>.inputsTr  r  r  )r   r   ri  r  r   r   r   test_geomspace3_basic  s   
z%TestNPFunctions.test_geomspace3_basicc                 C   s  t ddt}|   | t}|ddd W d    n1 s!w   Y  | dt|j | t}|ddd W d    n1 sEw   Y  | dt|j | t}|ddd W d    n1 siw   Y  | dt|j | t}|d	dd W d    n1 sw   Y  | d
t|j | t}|dd	d W d    n1 sw   Y  | d
t|j d S )NTr  r  r|  r  r  r  z%The argument "num" must be an integerr   r  )	r   r   r  r  r   r  r  r  r  r  r   r   r   test_geomspace3_exception  s@   z)TestNPFunctions.test_geomspace3_exceptionc                 C   s  t ddt}t ddt}t}|dd}| t|d |dddd}| |d d	 |ddd
d}| ||ddd
d |dddd}| ||dddd | dd |jD  |dddd}| ||dddd | dd |jD  |dddd}| ||dddd | dd |jD  d}d}|||dd}| |d | |||dd}| |d | | |d | tj	dd |dddd}W d    n1 sw   Y  | |d d | t
|dd   | |d d |dddd}| j||dddddd  | d!d |jD  |d"d#dd}| j||d"d#ddd$d  | d%d |jD  |d&d'dd}| j||d&d'ddd$d  |d(d)dd}| j||d(d)ddd$d  td*k rw|d+d,dd}| ||d+d,dd |d-d.d}| j||d-d.dd/d  |d-d0d}| j||d-d0dd/d  |d.d1d}| j||d.d1dd/d  |d-d.d}| j||d-d.dd/d  |d2d3d
}| j||d2d3d
dd  |d-d4d}| ||d-d4d |d4d-d}| ||d4d-d d S )5NTr  r   r'  r   r  r   r  rX  r  r  r~  r  c                 S      g | ]}|d kqS r  r   r@  r   r   r   r    r  z8TestNPFunctions.test_geomspace_numpy.<locals>.<listcomp>ic                 S   r  r  r   r@  r   r   r   r  
  r  c                 S   r  r  r   r@  r   r   r   r    r  r  gL4@r   ignore)invalidr  r  g      r  r  y              0@r|  r  r  c                 S   r  r  r   r@  r   r   r   r  '  r  y             y            @tvIh%<=c                 S   r  r  r   r@  r   r   r   r  +  r  r  y     @@     @@y            ?y     @     @@r  r  r  r  y              gV瞯<y      @        y              y             y      @      @r}  )r   r   r   r  r  ri  r,  imagr   Zerrstaterf  rt  realr   )r\  cfunc2Zcfunc3Zpfunc3r   r|   r}   r   r   r   test_geomspace_numpy  s   

z$TestNPFunctions.test_geomspace_numpyc                 C   sF   t }tdd|}dd }| D ]}||}||}| || qd S )NTr  c                   s   L    t dddV  t ddddV  t dddddddV  d S Nr  r|  r~  r  r  r  r   r   r   r   r  P      z6TestNPFunctions.test_rot90_basic.<locals>.a_variations)r   r   ri  )r\  rj  rp  r  r*   rr  rq  r   r   r   test_rot90_basicL  s   
z TestNPFunctions.test_rot90_basicc                 C   sZ   t }tdd|}dd }| D ]}tddD ]}|||}|||}| || qqd S )NTr  c                   s   r  r  r  r   r   r   r   r  ^  r  z=TestNPFunctions.test_rot90_with_k_basic.<locals>.a_variationsr}  r  )r   r   rZ  ri  )r\  rj  rp  r  r*   r   rr  rq  r   r   r   test_rot90_with_k_basicZ  s   


z'TestNPFunctions.test_rot90_with_k_basicc                 C   s  t }tdd|}|   | t}|d W d    n1 s!w   Y  | dt|j | t}|t	d
dddd W d    n1 sLw   Y  | dt|j | t}|t	d	 W d    n1 sqw   Y  | d
t|j d S )NTr  r  z'The first argument "m" must be an arrayr  r~  r  z*The second argument "k" must be an integerr  zInput must be >= 2-d.)r   r   r  r  r   r  r  r  r   r  r  r  r   r   r   test_rot90_exceptioni  s&   
z$TestNPFunctions.test_rot90_exceptionc                 C   L   |}t dd|}dd }| D ]}|| }|| }tj|t| qd S )NTr  c                  s   sJ   t d} | dfV  | ddfV  | g dfV  t| g dfV  t| g dfV  | g ddfV  t| g ddfV  t| g ddfV  t dddd} | dfV  | ddfV  | ddfV  | g dfV  | g ddfV  | g ddfV  | dd	gfV  | dd	gdfV  | dd	gdfV  | dgd
fV  | dgdfV  | dgdfV  | t jg t jddfV  t ddd
} | dfV  | ddfV  | dgdfV  | ddfV  | t ddddfV  | dfV  | t ddffV  t g } | dfV  | dfV  | ddfV  | ddfV  t g g} | dfV  | ddfV  | ddfV  | ddfV  d S )Nr  r~  r   )r   r  H   r  r  r   )r~  r   r|  r  r  r  r  r   r   r  r   r  )r   r  r  r  r  r  r  r  rA   r   r   r   args_variations  sT   








z5TestNPFunctions._check_split.<locals>.args_variationsr   r   r  Zassert_equalr  r\  r  rj  rp  r  r[   rr  rq  r   r   r   _check_split  s   
/zTestNPFunctions._check_splitc                 C   r  )NTr  c                   s   sV    t ddfV  tt ddfV  tt ddfV  t ddddfV  d S )Nr  r  r  r  r~  r|  )r   r  r  r  r  r   r   r   r   r    s
   z;TestNPFunctions._check_array_split.<locals>.args_variationsr  r  r   r   r   _check_array_split  s   
z"TestNPFunctions._check_array_splitc                 C   s   |  t | t d S r   )r  r   r  r[  r   r   r   test_array_split_basic  r  z&TestNPFunctions.test_array_split_basicc                 C   s   |  t |   | t}tttdd W d    n1 s#w   Y  | dt	|j
 | t}tttddgdd W d    n1 sNw   Y  | dt	|j
 d S )Nr|  r~  z0array split does not result in an equal divisionr  r  r5   z%np.split: Argument axis out of bounds)r  r   r  r  r  r   r   r  r  r  r  )r\  r  r   r   r   test_split_basic  s   
z TestNPFunctions.test_split_basicc              	   C   s   dd }dd }dd }| | | g}t ddftd	d
ftddffD ]*\}}}|}t|}	t|dD ]}
||
d	  D ]\}}| ||||	|| q:q2q"d S )Nc                   s   s.    t g ddfV  t g ddfV  d S )Nr  r~  rw  rO  r        @r  r   r   r   r   inputs1D  s   z5TestNPFunctions.test_vhdsplit_basic.<locals>.inputs1Dc                   s   s    t g dg dgdfV  t g dg dgdfV  t ddddfV  t dddt ddgfV  t dddddgfV  t ddddfV  t d	ddddfV  d S )
Nr  r~  r        0@r  r  r  r  r  r  r  r   r   r   r   inputs2D  s   "z5TestNPFunctions.test_vhdsplit_basic.<locals>.inputs2Dc                   s   s    t g dg dgg dg dggdf t dddddfV  t ddddt ddgfV  t ddddddgfV  t dddddfV  t dddddfV  d S )	Nr  r~  r  r  r  r  r  r  r  r   r   r   r   inputs3D  s   
$z5TestNPFunctions.test_vhdsplit_basic.<locals>.inputs3Dr~  r   r   r   r  r   r  )r   r   r   r   rZ  ri  )r\  r  r  r  r   fmindimnamerj  rp  r^  r*   r   r   r   r   test_vhdsplit_basic  s$   
z#TestNPFunctions.test_vhdsplit_basicc              	   C   s  t ddftddftddffD ]\}}}tdd|}|   | t}|dd W d    n1 s3w   Y  | d	t|j	 | t}|d
d W d    n1 sVw   Y  | d	t|j	 | t}|t
g dg dgd
 W d    n1 sw   Y  | dt|j	 | t}|t
dd W d    n1 sw   Y  | |d t| d t|j	 qd S )Nr~  r   r   r   r  r   Tr  z#The argument "ary" must be an arrayr  r  z:The argument "indices_or_sections" must be int or 1d-arrayz only works on arrays of z or more dimensions)r   r   r   r   r  r  r   r  r  r  r   r  r  )r\  r  r  r  rp  r  r   r   r   test_vhdsplit_exception
  sB   z'TestNPFunctions.test_vhdsplit_exceptionc           	      C   s^   t }tdd|}dd }dd }| D ]}| D ]}|||}|||}| || qqd S )NTr  c                   s   s~    t dV  t ddddV  g dV  dV  dV  dV  d	V  t t d
t jgt jdggV  t g V  dV  d S )Nr  r  r  r  r|  )r&  r  r(  r  F)r  r&  g333333@r   )r   r  r  r  r  r4  r  r   r   r   r   r  (  s   
"
z5TestNPFunctions.test_roll_basic.<locals>.a_variationsc                   S   s   t jdtddfS )Nr  r  r  r  r   r   r   r   shift_variations4  s   z9TestNPFunctions.test_roll_basic.<locals>.shift_variations)r   r   ri  )	r\  rj  rp  r  r  r*   r   rr  rq  r   r   r   test_roll_basic$  s   



zTestNPFunctions.test_roll_basicc              	   C   sv   t }tdd|}|   dD ])}|  }|td| W d    n1 s(w   Y  d}|t|jv s8J qd S )NTr  )r&  r  r  zshift must be an integer)r   r   r  r  r   r  r  r  )r\  rj  rp  r   r  rb  r   r   r   test_roll_exceptions>  s   
z$TestNPFunctions.test_roll_exceptionsc              	   C   s  t }tdd|}t| j||}td}| j| tddD ]}||k}|||d q td	dd	d
}|dk}|||d d}t
d
 }|||d g d}g d}|||d tddd}ddtjddddddf	}t|dD ]}|||d |t|	dd|d q{tg d}tg }|||d tg d}tg d}|||d tg dg dg}g d}|||d tg dg dg}tg d	ddd}|||d ttd	d
dd	}tdd}|||d |||d d d d td}dD ]
}|||d qd}d}|||d td}tddg}|||d td}tg d 	dd
d! }|||d d S )"NTr  r  r  r  r   r  r  r|  r  gffffff&@)r  r  r  r|  r  )r&  r  r(  rk  rw  r  r  Fr  rx  g333333r   rw  y              ?r~  r  )r   r   r   r   r  )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   rJ  r  )r   r   r   r   r   r   r  )r   r   r   r  r   r  rZ  ro  rZ  r  eyeflattenr|  r4  rc  combinations_with_replacementr  r  r  )r\  rj  rp  r  r*   	thresholdr  r]  r   r   r   test_extract_basicL  sd   




z"TestNPFunctions.test_extract_basicc                    s4  t }tdd|   tg }tg d}t} || W d    n1 s.w   Y  dt|j	  fdd}tg dg dg}g d}||| tg d}tg d}||| td	}d
}||| t
d}tg d}||| t
d}tg d}||| d S )NTr  r  z"Cannot extract from an empty arrayc                    sN   d} t} | | W d    n1 sw   Y  |t|j d S )Nz+condition shape inconsistent with arr shaperr  )r  r*   rb  r  r  r   r   r    s
   z7TestNPFunctions.test_extract_exceptions.<locals>._check)r   r   r   r   r   r   r   )r   r   r   r   r   r  rJ  r  )TFFFT)TFTFFTF)r   r   r  r   r  r  r  r  r  r  r  )r\  rj  r*   r  r  r  r   r  r   test_extract_exceptions  s2   







z'TestNPFunctions.test_extract_exceptionszNew in numpy 2.0+c                 C      | j td d S N)rj  )test_np_trapz_basicr   r[  r   r   r   test_np_trapezoid_basic     z'TestNPFunctions.test_np_trapezoid_basicc                 C   s8  t dd|}t| j||}g d}|d|i d}|d|i tddd}|d|i td	d
dddd}|d|idd | j| |d|idd t	g }|d|i t	dtj
tjtj dg}|d|i tdtdd
dd  }|d|i tj	g tjd}|d|i d}|d|i d S )NTr  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|  rZ  ro  r  r4  r  r  r\  rj  rp  r  r   r   r   r   r*    s,   
z#TestNPFunctions.test_np_trapz_basicc                 C   r(  r)  )test_np_trapz_x_basicr   r[  r   r   r   test_np_trapezoid_x_basic  r,  z)TestNPFunctions.test_np_trapezoid_x_basicc                 C   s(  t dd|}t| j||}g d}g d}|||d g d}d}|||d d}g d}|||d tg d}d	d	g}|||d tg }td
dg}|||d d}d }|||d tddd	}td	dg}|||d tddd	}tg d}|||d tddd	d}td	dg}|||d tddd	d}tg d}|||d tddd	d}| j| |d }| j| |||d td}|t	dddd  }|||d tg d}tddg}|||d d S )NTr  r  r  r  r  r   r  )r  r  r  r|  r  r  r  r  r~  r  r  r|  r  r  )r  r|  r  r&  r   r  r  r  r  )
r   r   r  r   r  r  r  rZ  ro  r|  )r\  rj  rp  r  r   r   r   r   r   r.    sV   

z%TestNPFunctions.test_np_trapz_x_basicc                 C   r(  r)  )test_trapz_numpy_questionabler   r[  r   r   r   !test_trapezoid_numpy_questionable  r,  z1TestNPFunctions.test_trapezoid_numpy_questionablezNumPy behaviour questionablec                 C   sZ   t dd|}t| j||}tg dt}|d|i tg d}|d|i d S )NTr  )TFTTr   )r   r   r  r   r  r5  r  r-  r   r   r   r2    s   z-TestNPFunctions.test_trapz_numpy_questionablec                 C   r(  r)  )test_np_trapz_dx_basicr   r[  r   r   r   test_np_trapezoid_dx_basic,  r,  z*TestNPFunctions.test_np_trapezoid_dx_basicc                 C   s  t dd|}t| j||}g d}d}|||d g d}g d}|||d g d}g d}|||d tdd	d
}tj}|||d tdd	d
}tj}|||d tdd	d
}tdd	d}|||ddd tddd	dd }tddd	d}|||d tdd
d}|t	d|d  t
dtj  dd}tj|dd td}d}|||d td}td	g}|||d d S )NTr  r  r~  r   r  )r   r  r|  r  r  r|  r  r  r  r  r  r  r  r  rI  r  r  r{  r   r   r  r  )r   r   r  r   r|  r4  r  r  r  expr?  r  r  assert_almost_equalr  )r\  rj  rp  r  r   r   r   r  r   r   r   r4  0  s@   *

z&TestNPFunctions.test_np_trapz_dx_basicc                 C   r(  r)  )test_np_trapz_x_dx_basicr   r[  r   r   r   test_np_trapezoid_x_dx_basic]  r,  z,TestNPFunctions.test_np_trapezoid_x_dx_basicc                 C   s   t dd|}t| j||}d dtg dfD ]S}g d}g d}||||d g d}dd	g}||||d g d}g d
}||||d tdddd}| j| |d }tj	|d< ||||d qd S )NTr  r~  r  r  r0  r   r  r  r1  r  r|  r  r&  r  )
r   r   r  r   r  r  r  rZ  ro  r4  )r\  rj  rp  r  r   r   r   r   r   r   r8  a  s$   
z(TestNPFunctions.test_np_trapz_x_dx_basicc                 C   r(  r)  )test_np_trapz_x_dx_exceptionsr   r[  r   r   r   !test_np_trapezoid_x_dx_exceptionsy  r,  z1TestNPFunctions.test_np_trapezoid_x_dx_exceptionsc              	      s  t dd|    fdd}g d}g dg dfD ]	}|||df qtd	d
dd}tdd
dd
}|||df td	d
dd}tg d}|||df g d}tddg}||d |f td	d
dd}td	d
dd}||d |f  }td}||d df W d    n1 sw   Y  dt|j	 ddtj
fD ]%} } |d d W d    n1 sw   Y  dt|j	 qd S )NTr  c                    sH    t} |   W d    n1 sw   Y  dt|j d S )Nzunable to broadcastrr  )r  r  r  r   r   check_not_ok  s   
zCTestNPFunctions.test_np_trapz_x_dx_exceptions.<locals>.check_not_okr  )r  r|  r  r  r  r  r  rw  r  r  r  r|  $   r  rO  zy cannot be 0DFzy cannot be a scalar)r   r  r   r  r  r  r  r  r  r  r4  )r\  rj  r<  r   r   r   r  r   r  r   r:  }  s:   


z-TestNPFunctions.test_np_trapz_x_dx_exceptionsc                    s  d}t j|d }t j|d }t |}t j|dk}t j|dk}t jjd|d}t jjd|d}d}	d}
d}t j|	|
|d }t j|	|
|d }t}tdd| j|||d	 ||d	d
d j|||d	 ||d	d
d j|||d	 ||d	d
d j|||d	 ||d	d
d j|||d	 ||d	d
d j|||d	 ||d	d
d j|| |d
d j|| |d
d  fdd}|||d	  fdd} fdd}t 	d
d}t ddg}|||d	 ||d|d d S )Nr  rz  e   r4  r   r  Tr  rG   r  )Zplacesc                    P    t} | |d W d    n1 sw   Y  |j}t|d d S )NrG   z)Weights sum to zero, can't be normalized.)r  ZeroDivisionErrorr  r  r  datarH   r  errr  r   r   test_weights_zero_sum     
z;TestNPFunctions.test_average.<locals>.test_weights_zero_sumc                    r?  )NrG   zCNumba does not support average when shapes of a and weights differ.r  	TypeErrorr  r  r  rA  r  r   r   test_1D_weights  rE  z5TestNPFunctions.test_average.<locals>.test_1D_weightsc                    sR    t} | ||d W d    n1 sw   Y  |j}t|d d S )Nr   z)Numba does not support average with axis.rF  )rB  r6   rH   r  rC  r  r   r   test_1D_weights_axis  s   
z:TestNPFunctions.test_average.<locals>.test_1D_weights_axisr  rK  g      ?g      ?r   r   )r   rY  ranfr  r  r  r   r   ZassertAlmostEqualr  r  r   )r\  r   r*   rI   Zw0Za_boolZw_boolZa_intZw_intZd0rm  Zd2Za_3dZw_3drj  rD  rH  rI  rB  r   r  r   test_average  sV   
zTestNPFunctions.test_averagec              
   C   s  t }tdd|}ttjj}tj|gtjd}tddgtddgftddgtddgftddgtd	dgftdgtd	dgfd
ttjdgtdtjgf||fg}|D ]\}}|||}|||}| 	|| qctdtj
g}tdtj
g}| ||| | 	|||dd|||dd ttj
dg}| 	|||||| g d}	td}
tjd}|	D ]}|	D ]}|	D ]}||
|||d}||
|||d}| 	|| |||
||d}|||
||d}| 	|| |t|g|
||d}|t|g|
||d}| 	|| |||| ||d}|||| ||d}| 	|| ||| |||d}||| |||d}| 	|| qqqd S )NTr  r   r  r!  r   ri   r"  r#  )rw  rw  r   r   rw  ro   )rw  r  g{Gz?gMbP?-C6?rh   gư>r1  )r  r  )rn   rm   )r   r   r   rr   int_r}  r  r   r  r  r4  ZassertFalser  rY  rJ  )r\  rj  rp  min_intr*   Zsimple_datar+   Z	py_resultZc_resultZnoise_levelsZ
zero_arraynoiserm   rn   r   r   r   test_allclose  sx   



zTestNPFunctions.test_allclosec           
      C   s  t }tdd|}tddg}tdjtjdd}d}d	}td
dgtd
dgft|gtdgftdgtd
| | gf||||  f||||  |d  f||||  ftj	tj	ftj	ttj	gfg}|D ]\}}	| 
|||	|||	 qsd S )NTr  g      Y@g     @@}   r   r|  r|  r|  ri   rh   r   r   r1  rw  r~  )r   r   r   r  r  r5  r  r  r   r  r  )
r\  rj  rp  r8   r*  rn   rm   
numpy_datar   r   r   r   r   test_ip_allclose_numpy>  s$   
z&TestNPFunctions.test_ip_allclose_numpyc           	      C   s  t }tdd|}tdjtjdd}d}d}ttjdgtd	tjgfttjdgtd	dgfttjtjgtd	tjgfttjtjgtd	d
gfttj d
gttjd
gfttj	d
gttj	d
gft|d gtd
gftd	gtd| |d  gf||||  |d  ft
tjd	gt
d
tjgfg
}|D ]\}}| |||||| qd S )NTr  rR  r   rS  ri   rh   r   rw  r1  r~  r   )r   r   r   r  r5  r  r  r   r  r4  r  r  )	r\  rj  rp  r*  rn   rm   rT  r   r   r   r   r   test_ip_not_allclose_numpyW  s&     "z*TestNPFunctions.test_ip_not_allclose_numpyc                 C   sJ   t }tdd|}G dd dtj}|dg}| t|||tu  d S )NTr  c                   @      e Zd Zdd ZdS )z?TestNPFunctions.test_return_class_is_ndarray_numpy.<locals>.Fooc                 _   s   t j|i || S r   )r   r  r  )clsr[   ro  r   r   r   __new__y  s   zGTestNPFunctions.test_return_class_is_ndarray_numpy.<locals>.Foo.__new__N)__name__
__module____qualname__rY  r   r   r   r   Foox  s    r]  r   )r   r   r   ndarrayr,  r  r  )r\  rj  rp  r]  r*   r   r   r   "test_return_class_is_ndarray_numpyr  s
   
z2TestNPFunctions.test_return_class_is_ndarray_numpyc                 C   sF   t }tdd|}tdtjg}| |||dd|||dd d S )NTr  rw  rL  )r   r   r   r  r4  r  )r\  rj  rp  r   r   r   r   test_equalnan_numpy  s   z#TestNPFunctions.test_equalnan_numpyc                 C   st   t }tdd|}ttjdg}tdtjg}||| tj|ttjdg tj|tdtjg d S )NTr  r   r   )r   r   r   r  r  r  r  )r\  rj  rp  r   r   r   r   r   $test_no_parameter_modification_numpy  s   
z4TestNPFunctions.test_no_parameter_modification_numpyc                 C   sN   t }tdd|}ttjj}tj|gtjd}| |||||| d S )NTr  r   )r   r   r   rr   rN  r}  r  r  )r\  rj  rp  rO  r*   r   r   r   test_min_int_numpy  s
   z"TestNPFunctions.test_min_int_numpyc                 C   s   |    t}tdd|}tddtjgtddgdddd	tfd
dddddtfdd
ddddtfddddddtfddddddtfddddddtfg}|D ]'\}}}}}}	}
| |
|	 |||||| W d    n1 sow   Y  qMd S r.  )	r  r   r   r   r   r4  r  r   r/  r0  r   r   r   test_allclose_exception  sH   




z'TestNPFunctions.test_allclose_exceptionc                 C   s  t }tdd|}t| j||dd}tddd}tdd	}|d
 }||||dd | j| ||||dd | j| ||||dd tj	|d d< tj
|dd < | j| ||||dd tj	|d d< tj
 |dd < | j| ||||dd tdd	}|d }|d }||||dd d}d}d}||||dd d}tddd}tdd}||||dd tdtj	tj
tj
 ddg}|jdddd}tddd}tdd}||||dd tddD ]}g d}d}||||dd qtg }g d}d}||||dd tdddddd}td }|d }||||dd tj	}td}tdtj	}||||dd tj	}dg}dg}||||dd tdd	}|}|}||||dd dd!g}tdd	}|}||||dd tj
 d"dd#tj
g}tdd	}|d$ }||||dd td%dd}ttj
 d"dd#tj
g}|d$ }||||dd | jd&}td'dd&}tjd&d(d)}||||dd d*D ]}tg d| }ddg}ddg}||||dd qd}dg}dg}||||dd tddd}tddd}tddd+}	||	||}
tj|
|	 tg d,}tg d,}tg d-}||||dd dg}tj
g}|d||dd tg d.}tg d,}tddtj	dg}||||d tg d/}tg d0}ttj	dtj	dtj	g}||||d tg d.}tg d,}tddtj
dg}||||d tdd
tj	d1tj
 dd2dtj
dd3g}tg d4}tddtj	ddtj
g}||||d tg d5}tddd6}t|d7 }||||d | jddtj d8}tddtj d9}t|}t|}||||}tjj||d:d; | jd}td%dd9}t|}||||d | jd9}td%dd}t|}||||d d S )<NTr  r%  r  r}  r|  r  r  r  rn  r   )r  r   r~  r  r(  g      r~  r  r  r  )rd  )r  ?r  r  r  gffffff?r1  g333333"r  r  r  r  rQ  r!  r   r  r  Frx  rw  r  r  r  r  r  rU  )r   r  r   r  )r   r~  gGz@r  )r   r~        @r  r  )	r   rn  r~  rg  r  r  r  r|  g      @r  rg  r  r  r   r~  r  r  r|  r  )g~@g<ԛ@g3@i!N  rO  )r  r  rh   )rn   )r   r   r   r  r   r|  r  rZ  ro  r4  r  r  r  rZ  r   r  r  r7  sinuniformr  cosr  Z	ones_like)r\  rj  rp  r  r   r   r  factorr   x0rf   exactrq  r   r   r   test_interp_basic  s  


(



z!TestNPFunctions.test_interp_basicc                 C   s|   |j d }t|| jjt|j |ddtj t|| jjt|j |ddtj  t|| jjt|j |ddtj d S )Nr  F)replace)r  r   putrZ  r[  rZ  r4  r  )r\  r*   r&  r   r   r   _make_some_values_non_finitef  s   
$&(z,TestNPFunctions._make_some_values_non_finitec              	   c   sh   t ddd|d  V  t ddd| V  t ddd|d  V  t ddd|d  V  t d	d
d|d  V  t ddd| d V  t ddd|d  d V  t ddd| d V  t ddd|d  d V  t ddd|d  dt t d|d  t j d|d     V  t ddd| | jjd| d| d V  t ddd| | jjd| d| d V  t ddd| | jjd| d| d V  t ddd| | jjd| d| d V  t ddd| | jjd| d| d V  t ddd| | jjd| d| d V  | jd| d d V  | jd|d  d d V  d S )NrO        @r   r|  r(  g333333@r~  g      @r&  rl  g@g333333@gq=
ףp?g @gQ?r  rz  )r  scale      @g      4@g      I@g      i@r&  g333333?r  rf  )r   r|  ri  r  r  rZ  normalr  )r\  ndatar   r   r   r  l  sB   "






"zTestNPFunctions.arraysc           
      C   s  t }tdd|}d}tddd| }t|d }| |D ]}d}||||}||||}	| j||	|d	 | j| ||||}||||}	| j||	|d	 | j| ||||}||||}	| j||	|d	 | j| ||||}||||}	| j||	|d	 | 	| ||||}||||}	| j||	|d	 | 	| ||||}||||}	| j||	|d	 | 	| ||||}||||}	| j||	|d	 q d S )
NTr  i N  r   r  r   rO  r  r  )
r   r   r   r|  ri  r  ri  rZ  ro  rr  )
r\  rj  rp  rw  r   r  r   rn   rr  rq  r   r   r   test_interp_stress_tests  sF   


z(TestNPFunctions.test_interp_stress_testszNEP 50 interaction issue.c                 C   s$  t }tdd|}d}tddd| }t|d }| jtjtj tjgd|d d< | j	| t
|d }| jtjtj tjgd|d d< | j	| |d	|  }| |D ]2}||||}	||||}
tjj|	|
dd
 | j	| | j	| | j	| tjj|	|
dd
 q]d S )NTr  i  r   r  r   rO     r  rL  )r   r   r   r|  ri  rZ  r[  r  r4  ro  rk  r  r  r  )r\  rj  rp  rw  r   r  r  r  r   rr  rq  r   r   r    test_interp_complex_stress_tests  s(   $$z0TestNPFunctions.test_interp_complex_stress_testsc           	      C   s  t }tdd|}|   tg d}tg }tg }| t}|||| W d    n1 s4w   Y  d}| |t|j	 d}tg d}tddg}| t}|||| W d    n1 sjw   Y  d}| |t|j	 d}t
dd	d}t
d}|  }|||| W d    n1 sw   Y  d
}| |t|j	 d}t
d}t
dd	d}|  }|||| W d    n1 sw   Y  d}| |t|j	 d}t
d}t
d}|  }|||| W d    n	1 sw   Y  d}| |t|j	 d}t
dd tj}t
d}|  }|||| W d    n	1 s>w   Y  | |t|j	 d S )NTr  r  zarray of sample points is emptyr   r~  z#fp and xp are not of the same size.r  r  zxp must be 1Dzfp must be 1Dr  z:Cannot cast array data from complex dtype to float64 dtyper  )r   r   r  r   r  r  r  r  r  r  r  r  r  r5  rh  )	r\  rj  rp  r   r   r  r  rb  Zcomplex_dtype_msgr   r   r   test_interp_exceptions  sf   










z&TestNPFunctions.test_interp_exceptionsc                 C   s   t }tdd|}t| j||}tg d}ttj ddtjg}tddg}|||d}|| ttj d	d
tjg}tg d}tddg}|||d}|| d S )NTr  )r   r   r  r  r  ?r  rl  r   r   r  )r   r  r|  r   )r   r   r   r  r   r  r  )r\  rj  rp  r  r   r  r   r  r   r   r   "test_interp_non_finite_calibration+  s   z2TestNPFunctions.test_interp_non_finite_calibrationc                 C   s  t }tdd|}tddD ]Q}tj|tjd}tj|tjd}tjdd|d |gtjd}|d d d }||||}||||}	tjg dtd}
|
d d d }tj	
||
 tj	
|	| qtddd	}tddd	}d}tj	
||||| d
}tj	
||||| td
}tj	
||||| td
}tj	
||||| tj}tj	
||||| tddd	}tddd	}td
}tj	
||||| tddd}t|}tj	
|tj||d d S )NTr  r   r  r   r  r   r{  r|  r  rM  r1  )r   r   rZ  r   r  r`  r  r  rR  r  r7  r|  rg  r  r4  ri  r  )r\  rj  rp  r  r   ZypZincptsZdecptsZincresZdecresZinctgtZdectgtr   r   rm  r  r   r   r   test_interp_supplemental_tests>  s@   



z.TestNPFunctions.test_interp_supplemental_testsc                 C   sr   t }tdd|}tddd}tddddtddd d  }d}|d| d  }tj||||| d S )NTr  r   r   r|  r  r  )r   r   r   r|  r  r7  )r\  rj  rp  r   r   rm  Zy0r   r   r   &test_interp_supplemental_complex_testsg  s   $z6TestNPFunctions.test_interp_supplemental_complex_testsc                 C   s   t }tdd|}tjtjtjtjg}t|dD ]0}|\}}}tj	d|d}|d 
|}	tjddd|d}
||
||	}||
||	}| || qd S )NTr  r  r  r   r~  )r   r   r   rg  r  r  r  rc  r$  r  r5  r|  ri  )r\  rj  rp  ZdtypesZcomboZxp_dtypeZfp_dtypeZx_dtyper   r  r   rr  rq  r   r   r   -test_interp_float_precision_handled_per_numpys  s   
z=TestNPFunctions.test_interp_float_precision_handled_per_numpyc                 C   sf   dd }t }tdd|}| D ] }||}||}t|tjr)| |||f q| ||| qd S )Nc                  s   s    t dV  t dV  t ddV  t ddV  t dV  t ddV  t ddV  dD ]} t jg dd	|  d
V  t jg dd|  d
V  q1d S )Nz
2016-01-01NaTmsnsz2038-01-19T03:14:07"   )r  r   WDhr   rc  r  usr  Zpsfsas){   ir  z<datetime64[%s]r   z<timedelta64[%s])r   r
  r	  r  )unitr   r   r   r9     s    


z*TestNPFunctions.test_isnat.<locals>.valuesTr  )rq   r   r  r   r^  ri  r  r  r   r   r   
test_isnat  s   
zTestNPFunctions.test_isnatc           	         s   dd } fdd}t tfD ]l}tdd|}t j||}| D ]X}d|i}d|jv r=d tjfD ]
}||d	< || q1n|| tjd
tj	d}d|i}d|jv rsd |d	< ||d| tj|d	< ||d| tj	|d	< ||d| q!||d| q!qd S )Nc                  s   s    dV  dV  dV  dV  g dV  ddgV  dV  dV  g dg dfV  t g V  t dV  t dd	dV  t dd	djV  d
d } | dV  | dV  | dV  | dV  dS )a}  
            To quote from: https://docs.scipy.org/doc/numpy/reference/generated/numpy.asarray.html    # noqa: E501
            Input data, in any form that can be converted to an array.
            This includes:
            * lists
            * lists of tuples
            * tuples
            * tuples of tuples
            * tuples of lists
            * ndarrays
            r  r  Fr   r  r  r  r  r  c                 S   s   t  }| D ]}|| q|S r   r	   r7   )r9   r*   r^  r   r   r   	make_list     zITestNPFunctions.test_asarray.<locals>.input_variations.<locals>.make_list)rw  rO  r  r  r  N)r   r  r  r  r  )r  r   r   r   r    s&   




z6TestNPFunctions.test_asarray.<locals>.input_variationsc                    sd   | di |}|r  ||d u  d S   ||d u tj||d    |j|d k d S )Nr*   r   r   )r,  r   r  r  r   )ZjittedZexpect_samer  returnedr[  r   r   check_pass_through  s   z8TestNPFunctions.test_asarray.<locals>.check_pass_throughTr  r*   kwsr   r  r   F)
r   r   r   r   r  rZ  r   r  r  rg  )	r\  r  r  rj  rp  r  r   r  rb  r   r[  r   test_asarray  s2   (






zTestNPFunctions.test_asarrayc           
      C   s`   dd }dd }dd }dd }||||g}|D ]}t d	d
|}| }| }	| ||	 qd S )Nc                   S   s
   t dS Nr  r   r   r   r   r   case1  r    z3TestNPFunctions.test_asarray_literal.<locals>.case1c                  S      d} t | S r  r   rc  r   r   r   case2     
z3TestNPFunctions.test_asarray_literal.<locals>.case2c                  S   r  )Nu+   大处 着眼，小处着手。大大大处r   r  r   r   r   case3  r  z3TestNPFunctions.test_asarray_literal.<locals>.case3c                  S   r  )N r   r  r   r   r   case4  r  z3TestNPFunctions.test_asarray_literal.<locals>.case4Tr  )r   ri  )
r\  r  r  r  r  funcsrj  rp  rr  rq  r   r   r   test_asarray_literal  s   z$TestNPFunctions.test_asarray_literalc                    sp      tddt  fdd}dd }dd }d	d
 }dd }||  ||  ||  ||  d S )NTr  c                    r  )Nz?asarray support for List is limited to Boolean and Number types)r  r   r  r  r  )alistr  r  r   r   test_reject  s   
zQTestNPFunctions.test_asarray_rejects_List_with_illegal_dtype.<locals>.test_rejectc                  S   s   t  } | d  | S r   r  )lr   r   r   make_none_typed_list  s   
zZTestNPFunctions.test_asarray_rejects_List_with_illegal_dtype.<locals>.make_none_typed_listc                  S   s$   t  } t  }|d | | | S )Nr   r  )r  r   r   r   r   make_nested_list  s
   

zVTestNPFunctions.test_asarray_rejects_List_with_illegal_dtype.<locals>.make_nested_listc                  S   s"   t  } t }d|d< | | | S )Nr*   r   )r	   r
   r7   )r  r  r   r   r   make_nested_list_with_dict   s
   
z`TestNPFunctions.test_asarray_rejects_List_with_illegal_dtype.<locals>.make_nested_list_with_dictc                  S   s   t  } dD ]}| | q| S )N)r*   bcdefr  )r  r^  r   r   r   make_unicode_list'  r  zWTestNPFunctions.test_asarray_rejects_List_with_illegal_dtype.<locals>.make_unicode_list)r  r   r   )r\  r  r  r  r  r  r   r  r   ,test_asarray_rejects_List_with_illegal_dtype  s   


z<TestNPFunctions.test_asarray_rejects_List_with_illegal_dtypec                 C   s   dd }t }tdd|}| D ]0\}}|d u r!||}||}n|||d}|||d}| || | t|jtj|j qt}tdd|}t	g d}||}||}| || | t|jtj|j d S )Nc                   s   s    t g dd fV  t jddgt jdt jfV  t jddgt jdt jfV  t jddgt jdt jfV  t jddgt jdt jfV  d S )Nr  r~  r  r   )r   r  rg  r6  rh  r  r   r   r   r   r   4  s    z-TestNPFunctions.test_asfarray.<locals>.inputsTr  r   r  )
r   r   ri  r,  r   r  r   Zinexactr   r  )r\  r   rj  rp  r8   rb  rr  rq  r   r   r   test_asfarray2  s$   
zTestNPFunctions.test_asfarrayc              	      s  t }t|}t}t|}||f||ffD ]\  fdd}tdtdtddgddggtg tg g gg}tjtjtj	tj
tjtjtjtjg}dd	 t||D }dd
ddg ddg}	t||	D ] }
||
dd ||
dd ||
dd ||
dd ||
dd qktd}dgdgdgfD ]}
|||
d ||t|
d qtd}ddgddgddgddgddgddgddgfD ]}
|||
d ||t|
d q||tjddgtjdd |tdtdd qd S )Nc                    s    | | | | d S r   rJ  r  nbfuncrj  r\  r   r   rv  ^  s   z*TestNPFunctions.test_repeat.<locals>.checkr   r  r   r~  r  c                 s   s"    | ]\}}t j||d V  qdS )r   Nr  )r  r*   tr   r   r   	<genexpr>u  s     z.TestNPFunctions.test_repeat.<locals>.<genexpr>rw  Tr  rQ  )r  r  r   r  )r  r   r  r   r  r  r  uint32r  uint64r  rg  r  rh  r  rc  r   r  )r\  r  r  array_pyfuncarray_nbfuncrv  Ztarget_numpy_valuesZtarget_numpy_typesZtarget_numpy_inputsZtarget_non_numpy_inputsr^  onetwor   r  r   test_repeatR  sl   	

2zTestNPFunctions.test_repeatc           	   
   C   st  t }t|}t}t|}|   ||f||ffD ]\}}| t}|tdd W d    n1 s5w   Y  | dt	|j
 | t}|tdd W d    n1 s[w   Y  | dt	|j
 | t}|tdtddg W d    n1 sw   Y  | dt	|j
 | t}|tdtg d W d    n1 sw   Y  | dt	|j
 | t}|td	tg d
 W d    n1 sw   Y  | dt	|j
 | t}|tdddg W d    n	1 sw   Y  | dt	|j
 dD ]!}| t |td| W d    n	1 s0w   Y  qqd S )Nr   r  z#negative dimensions are not allowedrw  zIThe repeats argument must be an integer or an array-like of integer dtyper~  rN  z(operands could not be broadcast togetherr|  r{  )Tr*   rV  )r  r   r  r  r  r  r   r  r  r  r  r   r  )	r\  r  r  r  r  rj  r  r  repr   r   r   test_repeat_exception  sj   z%TestNPFunctions.test_repeat_exceptionc           
      C   s  t }tt }tg dtg dtg dgtg dtg dtg dgdftdgtd	ggtd
gtdggdftd	ggd td
ggd dfttd
ddtjddggd td
ddtjddggd dfttd
ddtjddgggd td
ddtjddgggd dfttd
ddtjddggd td
ddtjddggd dfg}tdtddfD ]J}||dk |dkg||d gdf ||dk |dkf||d fdf ||dk |dkg||d fdf ||dk |dkf||d gdf q|D ]\}}}| 	|||||||| qt
}tt
}	| 	||||	|| d S )NFFFFTF)FFTr  r  r  g.@TFr   r~  r   r  r  r|  r  y      @       @r  )r|  r~  )r  r   r   r  rf  r4  r  r  r7   ri  r  )
r\  r  r  Z
test_casesr   r
  r  r  Znp_pyfunc_defaultsZnp_nbfunc_defaultsr   r   r   test_select  sT   

$"$ "$$$&
zTestNPFunctions.test_selectc           	      C   s.  t t}td}|   tdtg dgtdtdddgdtd	ftdtd
gtdgtdggdtdftdgtd
ggtdggtdgggdtdftdtd
gtdtdgdtd	fttdddtj	ddgtdddtj	ddgdtdfdgdgdgtdf|dk 
t|dk
tg||d gdtdf|dk|dk|dk|dkg||d |gdtdfdgd tdggd dtdftd
ggd dgd dtdff
D ],\}}}}}| |}|||| W d    n	1 sw   Y  | |t|j qd S )Nr  Tr  r   r  r  r  r   z/condlist arrays must be of at least dimension 1Fr~  zHcondlist and choicelist elements must have the same number of dimensionsr|  r  z"condlist must be a List or a Tuplezdefault must be a scalarz%condlist arrays must contain booleansr  r  r  z7list of cases must be same length as list of conditionsr  r  z items of condlist must be arraysr
  z"items of choicelist must be arrays)r   r  r   r  r  r  r  r   rf  r4  r5  r  r  r  r  r  r  )	r\  r  r   r
  r  r  Zexpected_errorZexpected_textr  r   r   r   test_select_exception  sT   
(&&*
/z%TestNPFunctions.test_select_exceptionc           	   	      s:   fdd}|t  |t |t |t t}tt}dD ],}dD ]'}|||}|||}ts6t dv r@ j	||ddd q" j	||ddd q"qd	D ]%} 
t}||d
 W d    n1 sdw   Y   dt|j qMdD ]%} 
t}|d| W d    n1 sw   Y   dt|j qud S )Nc              	      s   | }t | }dD ]}||}||} j||dd qdD ]$} t}|d W d    n1 s3w   Y   dt|j qd S )Nr   r   r|  r  r`  )ra  r*   r&  r  r&  M must be an integer)r   ri  r  r   r  r  r  )r  r  r  r   rr  rq  r  r[  r   r   check_window<  s   
z4TestNPFunctions.test_windowing.<locals>.check_windowr  )r1  ru  g      ,@)ppc64leaarch64r`  r~  r  r  rw  r  )r*   r  r|  z beta must be an integer or float)r  r  r  r  r  r   r   platformmachineri  r  r   r  r  r  )	r\  r  r  r  r   r  rr  rq  r  r   r[  r   test_windowing;  s@   


zTestNPFunctions.test_windowingc                 C   s4  t }tdd|}tg dg dgtg dg dgftg dg dgdftjg dtjdtjg dtjdfdtdd	gtg dftg dtg dg dgftg dg dgtg dftd
dd	dtdd	d	fg}|D ]\}}|||}|||}| || qd S )NTr  r  r  rN  r  r   )r  r  r   r~  r=  r  r  r  )	r  r   r   r  r  r  r  r  ri  r\  rj  rp  pairsr   r   rr  rq  r   r   r   
test_crossj  s<   +

zTestNPFunctions.test_crossc                 C   s  t }tdd|}|   | t}|tdtd W d    n1 s(w   Y  | dt|j	 | t}|t
dt
d W d    n1 sQw   Y  | dt|j	 | d	t|j	 | t}|td
dtdd d d d W d    n1 sw   Y  | dt|j	 | t}|td
dtd
d d d d W d    n1 sw   Y  | dt|j	 | t}|tg dtg d W d    n1 sw   Y  | dt|j	 d S )NTr  r  r  z)Incompatible dimensions for cross productr  r  z Dimensions for both inputs is 2.z+`cross2d(a, b)` from `numba.np.extensions`.r  r~  r  r  r  r  )r  r~  zDimensions for both inputs is 2r  r  Inputs must be array-like.)r  r   r  r  r  r   r  r  r  r  r  r  r   setr  r   r   r   test_cross_exceptions  sr   

z%TestNPFunctions.test_cross_exceptionsc                 C   s  t }tt}tddgddggtddgddggftddgddggdftjddgtjdtjddgtjdfdtddgtddgddggftddgddggtddgftdd	d
dtd	d
dfg}|D ]\}}|||}|||}| 	|| qsd S )Nr   r~  r  r|  r  r   )r  rN  r=  r  r  )
r  r   r  r   r  r  r  r  r  ri  r  r   r   r   test_cross2d  s6   &

zTestNPFunctions.test_cross2dc                 C   s$  t t}|   | t}|tdtd W d    n1 s#w   Y  | dt|j	 | t}|t
ddt
dd d d d W d    n1 sWw   Y  | dt|j	 | t}|tddgtd	d
g W d    n1 sw   Y  | dt|j	 d S )Nr  r  z,Incompatible dimensions for 2D cross productr  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   test_cross2d_exceptions  s@   

z'TestNPFunctions.test_cross2d_exceptionsc           	      C   s~   dd }dd }t }tdd|}| D ]}||}||}| || q| D ]\}}|||}|||}| || q(d S )Nc                   s   sr    t g V  t dV  t dV  t g dV  t g dV  t dddt jdgV  t g dV  d S )	Nr|  r   r  r  r1  rw  rO  )0Helloworld)r   r  r  r4  r   r   r   r   r  3  s   z/TestNPFunctions.test_trim_zeros.<locals>.arraysc                   s   s    t g ddfV  t g ddfV  t t jddddgdfV  t g d	d
fV  tdk rEt g ddfV  t g ddfV  t g dd
fV  d S )N)r   r   r~  r   r   ZFBrQ  Br1  r  ru  r+   )r   r   r   r~  r|  r  r  )r   r   r~  r   Zabf)r   r  r   r  ) rV  rW  )r   r  r4  r   r   r   r   r   explicit_trim<  s   z6TestNPFunctions.test_trim_zeros.<locals>.explicit_trimTr  )r  r   ri  )	r\  r  r  rj  rp  r8   rr  rq  r  r   r   r   test_trim_zeros1  s   	


zTestNPFunctions.test_trim_zerosc                 C   s  t g d}|t}|t}|||g}t jdd }|D ]}t|}| |||  qt jd d }|D ]}t|dd}| |||  q7t jdd  }|D ]}t|dd}| |||  qQ|D ]&}t j||j	d}t|dd}	t
|	d	ks|J t|d
d}
t
|
d	ksJ qdt d	}t|}| || t g dt g dt g dfD ]}t jdd }t|}| |||  qt g d}t|}| || t| }t|tsJ d S )N)r   r   r   r   r~  r  r  r   r~  r  r+   )r  r  r   r  r   r  )r   l            r   )r   l            r   )r   l            r   r   )Nr   N)r   r  r5  rR  rb  Zs_r  ri  Z
zeros_liker   r  r  r  r  r  )r\  r*   r+   r  r9   Zslcr8   resZ_arrZres1Zres2r   r   r   test_trim_zeros_numpyU  sH   



z%TestNPFunctions.test_trim_zeros_numpyc                 C   sL  |    tddt}| t}|tg dg dg W d    n1 s(w   Y  | dt|j	 | t}|d W d    n1 sJw   Y  | dt|j	 | t}|h d W d    n1 snw   Y  | dt|j	 | t}|tg d	d
 W d    n1 sw   Y  | dt|j	 d S )NTr  r  r  zarray must be 1Dr  z#The first argument must be an array>   r   r   r~  rQ  r   z$The second argument must be a string)
r  r   r  r  r   r   r  r  r  r  r  r   r   r   test_trim_zeros_exceptions  s<   
z*TestNPFunctions.test_trim_zeros_exceptionsc              	   C   s   t }tdd|}tg dtg dftg dg dgtg dftddddd	tg d
ftdddd	tdddd	dftg dtg dfg}|D ]\}}|||}|||}| || q]d S )NTr  r  re  )r~  r|  r  r   r  r~  r|  )r   r     r  )FTr  )r  r   r   r  r  r  ri  )r\  rj  rp  r  r*   r+   rr  rq  r   r   r   test_union1d  s.   

zTestNPFunctions.test_union1dc                 C   sj  t ddt}|   | t}|dtddg W d    n1 s%w   Y  | dt|j	 | t}|tddgd W d    n1 sMw   Y  | dt|j	 | t}|dd W d    n1 spw   Y  | dt|j	 | t}|tdd	gtd
dg W d    n1 sw   Y  | dt|j	 | t}|tddgtddg W d    n1 sw   Y  | dt|j	 | t}|tddgtddg W d    n1 sw   Y  | dt|j	 | t}|tddgtddg W d    n	1 s%w   Y  | dt|j	 d S )NTr  r  r   r~  z.The arguments to np.union1d must be array-likeZWorldr  r  r*   r+   z/For Unicode arrays, arrays must have same dtyper  r  r  barr&  rg  )
r   r  r  r  r   r   r  r  r  r  r  r   r   r   test_union1d_exceptions  sf       z'TestNPFunctions.test_union1d_exceptionsc                 C   s   t }tdd|}|   tg dtjftg dfg dftddgddggtjfd	tjftjddgtjd
ftddddfg}|D ]}|| }|| }| 	|| qJd S )NTr  r  r  r   r~  r  r  )r  r  r   r=  r  )
r  r   r  r   r  rg  r  r  r  ri  )r\  rj  rp  r  pairrr  rq  r   r   r   test_asarray_chkfinite  s4   "z&TestNPFunctions.test_asarray_chkfinitec                 C   sZ  t ddt}|   | t}|d W d    n1 sw   Y  d}| |t|j | t}|t	
ddt	jdg W d    n1 sKw   Y  | dt|j | t}|t	
ddt	jdg W d    n1 suw   Y  | dt|j | t}|t	
g d	d
 W d    n1 sw   Y  | dt|j d S )NTr  r~  z7The argument to np.asarray_chkfinite must be array-liker  r|  z#array must not contain infs or NaNsr   r  rg  z!dtype must be a valid Numpy dtype)r   r  r  r  r   r  r  r  r  r   r  r4  r  )r\  rp  r  rb  r   r   r   !test_asarray_chkfinite_exceptions0  s&   
z1TestNPFunctions.test_asarray_chkfinite_exceptionsc              	      s  t }t|}t}t|}t}t|}t}t|}dd }	|	 D ]}
| ||
||
 qtg d}t|d  fdd}| | ddd| ddd | D ]\}
}| ||
|d	||
|d	 qR fd
d}| D ]\}
}}| ||
||d||
||d qnd S )Nc                  s   s    t dddt j  gV  t jdt jdd} | dd   t j7  < | V  t ddV  t jd	d
ddV  t jdd
ddV  d S )Nr   r~  r   r|  r   r  r  )r  r     r  )step   re  )r   r  r  r|  r  r  )Zphaser   r   r   inputs1Z  s   z2TestNPFunctions.test_unwrap_basic.<locals>.inputs1)r   K         r3  i     c                   3   s`    t ddgdfV  t g ddfV  t g ddfV  t g ddfV   dfV  d S )	Nr   i     )r   r  r  r  r3  )r   r   r~  r  r   r  )r~  r  r  r|  r~  r  r  r|  r  r  r   Zwrap_unevenr   r   inputs13j  s   z3TestNPFunctions.test_unwrap_basic.<locals>.inputs13r  )r6   r#  r"  c                   3   s     ddfV  d S )Nr     r   r   r  r   r   	inputs123z  s   z4TestNPFunctions.test_unwrap_basic.<locals>.inputs123r*  )	r%  r   r(  r)  r+  ri  r   r  mod)r\  rj  rp  r  cfunc1Zpyfunc13Zcfunc13Z	pyfunc123Zcfunc123r  r&  Z
uneven_seqr  r#  r  r'  r   r  r   test_unwrap_basicI  s>   
	

z!TestNPFunctions.test_unwrap_basicc                 C   s  t t}|   | t}|d W d    n1 sw   Y  | dt|j | t}|t	ddgd W d    n1 sDw   Y  | dt|j | t}|t	ddgddd W d    n1 snw   Y  | dt|j | t}|t	ddgddd	 W d    n1 sw   Y  | d
t|j | t
}|t	ddgddd	 W d    n1 sw   Y  | dt|j d S )Nr  z#The argument "p" must be array-liker   r~  z'The argument "discont" must be a scalarr  r"  z&The argument "period" must be a scalarr5   z&The argument "axis" must be an integerz*Value for argument "axis" is not supported)r   r%  r  r  r   r  r  r  r   r  r  )r\  rp  r  r   r   r   test_unwrap_exception  s@   
z%TestNPFunctions.test_unwrap_exceptionc           	      C   sz   t }tdd|}dd }| D ]*}t|j |jD ]}t|j |jD ]}||||}||||}| || q$qqd S )NTr  c                   s   s<    t dV  t dddV  t ddddV  d S )Nr  r~  r|  r  r  r  r  r   r   r   r   r    s   z9TestNPFunctions.test_swapaxes_basic.<locals>.a_variations)r.  r   rZ  ndimri  )	r\  rj  rp  r  r*   r/  r0  rr  rq  r   r   r   test_swapaxes_basic  s   
z#TestNPFunctions.test_swapaxes_basicc                 C   s  t }tdd|}|   | t}|ddd W d    n1 s#w   Y  | dt|j | t}|t	ddd W d    n1 sJw   Y  | dt|j | t}|t	ddd W d    n1 sqw   Y  | dt|j | t
}|t	dd	d W d    n1 sw   Y  | d
t|j | t
}|t	ddddd W d    n1 sw   Y  | dt|j d S )NTr  r  r   z'The first argument "a" must be an arrayr  z.The second argument "axis1" must be an integerz-The third argument "axis2" must be an integerr   z)np.swapaxes: Argument axis1 out of boundsr  r~  r  z)np.swapaxes: Argument axis2 out of bounds)r.  r   r  r  r   r  r  r  r   r  r  r  r  r   r   r   test_swapaxes_exception  sB   z'TestNPFunctions.test_swapaxes_exceptionc                 C   s   t dd}tdd }t jddgt jd}| |||||| dd	 }td
|j	D ]}||}t j
||d}| |||||| q/d S )Nr  )r  r   r  r~  c                 S   s   t j| |d dS r4   r   Ztake_along_axisr*   r^  r   r   r   	axis_none  r,  z7TestNPFunctions.test_take_along_axis.<locals>.axis_noner   r~  r   c                       t  fdd}|S )Nc                       t | | S r   r  r  r5   r   r   impl  r  z?TestNPFunctions.test_take_along_axis.<locals>.gen.<locals>.implr   r6   r  r   r5   r   gen     z1TestNPFunctions.test_take_along_axis.<locals>.genr  r5   )r   r  r  r   r  r  ri  r  rZ  r  r  )r\  r*   r  r   r  r^  Zjfuncair   r   r   test_take_along_axis  s   

z$TestNPFunctions.test_take_along_axisc                 C   sh   t d}t jdt jd}dd }dD ]}||}|||}|||}| || | |jd qd S )N)r  r  r   )r   r~  r|  r   c                    r  )Nc                    r  r   r  r  r5   r   r   r    r  zLTestNPFunctions.test_take_along_axis_broadcasting.<locals>.gen.<locals>.implr  r  r   r5   r   r    r  z>TestNPFunctions.test_take_along_axis_broadcasting.<locals>.gen)r   r  )r  r~  r|  )r   r  Zintpr  ri  r  r  )r\  r8   r  r  r^  rv  rr  actualr   r   r   !test_take_along_axis_broadcasting  s   

z1TestNPFunctions.test_take_along_axis_broadcastingc                 C   sf  t ddd}t jddgt jd}t jdt jd}dd	 }| t}|d
|| W d    n1 s6w   Y  | dt	|j
 | t}|d|| W d    n1 s[w   Y  | dt	|j
 | t}|d|| W d    n1 sw   Y  | dt	|j
 | t}|d d| W d    n1 sw   Y  | dt	|j
 | t}|d |d W d    n1 sw   Y  | dt	|j
 | t}|d |t ddg W d    n1 sw   Y  | dt	|j
 tdd }| t}|||d W d    n	1 sw   Y  | dt	|j
 | t}|d|t jddgt jd W d    n	1 sMw   Y  | dt	|j
 | t}|d || W d    n	1 ssw   Y  | dt	|j
 | t}|d|t jdt jd W d    n	1 sw   Y  | dt	|j
 |   d S )Nr  r~  r  r   r   r   r  c                    r  )Nc                    r  r   r  r  r5   r   r   r    r  zJTestNPFunctions.test_take_along_axis_exceptions.<locals>.gen.<locals>.implr  r  r   r5   r   r  
  r  z<TestNPFunctions.test_take_along_axis_exceptions.<locals>.genr*   zaxis must be an integerr  zaxis is out of boundsr  z"arr" must be an arrayr|  z"indices" must be an arrayr1  rw  z#indices array must contain integersc                 S   r.   r   r  )r*   r^  r6   r   r   r   not_literal_axis+  r  zITestNPFunctions.test_take_along_axis_exceptions.<locals>.not_literal_axiszaxis must be a literal valuez'must have the same number of dimensionsr  zdimensions don't match)r   r  r  r  r  r  r  r   r  r  r  r   r  r  )r\  Zarr2dZindices_noner   r  r  r  r   r   r   test_take_along_axis_exceptions  sl   
 z/TestNPFunctions.test_take_along_axis_exceptionsc           	      C   sH  t jdddtt j t jtt jt jt jdgtdt tt j t jtdt jtt jdtt jt j gt g dt g dt g dg dgt dt jd	gt dt jd	gt jd
dggt t j t jt jgt jt j t jt jgt jdg}ddg}t}tt}t	||D ]\}}|||d}|||d}| 
|| qd S )Nr   r&  r  r   )r  rw  皙?r  )r  r  r  r  r  r  r  r1  r  )r4  )r   r4  rb  r  r  r  rg  r5  r   r   ri  )	r\  r9   r`  rj  rp  valuer4  rr  rq  r   r   r   test_nan_to_numD  s4   zTestNPFunctions.test_nan_to_numc                 C   sx   t t}tddtjg}d}||d|d | |d | tddttjtjg}||d|d | |d d d S )Nr  r  rw  Fr2  r  r  )r   r5  r   r  r4  ri  rb  )r\  rp  r   rr  Z	x_complexr   r   r   test_nan_to_num_copy_falsec  s   z*TestNPFunctions.test_nan_to_num_copy_falsec                 C   sN   t t}|  }|d W d    n1 sw   Y  | dt|j d S )NZinvalid_inputz4The first argument must be a scalar or an array-like)r   r5  r  r  r  r  r  r   r   r    test_nan_to_num_invalid_argumentp  s   

z0TestNPFunctions.test_nan_to_num_invalid_argumentc                 C   s`   t }t|}t}t|}dd }| D ]\}}| |||| | |||||| qd S )Nc                   s   sj    t ddgdfV  t ddgddggdfV  t dddfV  ddgdfV  t g dfV  d S )Nr   r~  r  r  r  r  r  r  r   r   r   r   r   ~  s   z3TestNPFunctions.test_diagflat_basic.<locals>.inputs)r:  r   r;  ri  )r\  r  r  r  r   r   rP   r   r   r   r   test_diagflat_basicx  s   z#TestNPFunctions.test_diagflat_basicc                 C   s\   t }t|}|   | t}|d W d    n1 sw   Y  | dt|j d S )Nr  #The argument "v" must be array-like)r:  r   r  r  r   r  r  r  r  r   r   r   test_diagflat1_exception  s   
z(TestNPFunctions.test_diagflat1_exceptionc                 C   s   t }t|}|   | t}|dd W d    n1 sw   Y  | dt|j | t}|ddgd W d    n1 sDw   Y  | dt|j | t}|ddgd W d    n1 siw   Y  | dt|j d S )Nr  r~  r
  r   z#The argument "k" must be an integerr  )r;  r   r  r  r   r  r  r  r  r   r   r   test_diagflat2_exception  s*   z(TestNPFunctions.test_diagflat2_exceptionc                   c   s   t tjt tjfV  dgt tjfV  t tjdgfV  dgdgfV  dgdgfV  ddgdgfV  g dddgfV  g dg dfV  ddgddgfV  g dg dfV  g dddgfV  g dg d	fV  g dg d
fV  g dg dfV  d S )Nr   r~  r  r~  r~  r  r  r~  r  r  r   r  r  r  )r  r|  r  )r   r  r~  r  rh  r  r   r   r   r   _setxor_arrays  s"   

zTestNPFunctions._setxor_arraysc                    <   t t  fdd} D ]	\}}||| qd S )Nc                    X   t | tr	t| } t |trt|}| |} | |}j||d|  d| d d S Nzar1=z, ar2=rs  r  r  r	   ri  ar1ar2rr  rq  r  r  r\  r   r   rv       



 z.TestNPFunctions.test_setxor1d_2.<locals>.check)r=  r   r  r\  rv  r*   r+   r   r  r   test_setxor1d_2     	zTestNPFunctions.test_setxor1d_2c                    v   t t d fdd	} D ]%\}}||| tt|t|kr8tt|t|kr8|||d qd S )NFc                    \   t | tr	t| } t |trt|}| ||} | ||}j||d|  d| d d S r  r  r  r  r0   rr  rq  r  r   r   rv       

 z.TestNPFunctions.test_setxor1d_3.<locals>.checkTr  )r>  r   r  r  r   r  r  r   r  r   test_setxor1d_3     	
,zTestNPFunctions.test_setxor1d_3c                 C   r  r  )r>  r   r   r  r  r  r   r  r   r   r   test_setxor1d_errors  r  z$TestNPFunctions.test_setxor1d_errorsc                   c   s    t tjt tjfV  dgt tjfV  t tjdgfV  dgdgfV  dgdgfV  ddgdgfV  g dddgfV  g dg dfV  ddgddgfV  g dg dfV  g dddgfV  tg dtg d	fV  td
tdfV  tg dtg dfV  d S )Nr   r~  r  r  r  r  r  )r  r|  r  r  r   r~  r  r  )r~  r  r  r  r~  r   r|  r  r]  rK  )r  r|  r~  )r	   r  r   r  r   r  r  r   r   r   r   _setdiff_arrays  s&   

"zTestNPFunctions._setdiff_arraysc                    r  )Nc                    r  r  r  r  r  r   r   rv    r  z/TestNPFunctions.test_setdiff1d_2.<locals>.check)r@  r   r#  r  r   r  r   test_setdiff1d_2  r  z TestNPFunctions.test_setdiff1d_2c                    r  )NFc                    r  r  r  r  r  r   r   rv    r  z/TestNPFunctions.test_setdiff1d_3.<locals>.checkTr  )rA  r   r#  r  r   r  r  r   r  r   test_setdiff1d_3  r!  z TestNPFunctions.test_setdiff1d_3c                 C   r  r  )rA  r   r   r  r  r  r   r  r   r   r   test_setdiff1d_errors$  r  z%TestNPFunctions.test_setdiff1d_errorsc                   c   s    t tjt tjfV  dgt tjfV  t tjdgfV  dgdgfV  dgdgfV  ddgdgfV  g dddgfV  g dg dfV  ddgddgfV  g dg dfV  g dddgfV  ddgtdfV  ddgttd	d
fV  d S )Nr   r~  r  r  r  r  r  r  r|  r  )r	   r  r   r  r   r  rg  r   r   r   r   _in1d_arrays2  s    

 zTestNPFunctions._in1d_arraysc                    r  )Nc                    r  r  r  r  r  r   r   rv  G  r  z*TestNPFunctions.test_in1d_2.<locals>.check)rC  r   r'  r  r   r  r   test_in1d_2C  r  zTestNPFunctions.test_in1d_2c                    sx   t t d fdd	} D ]&\}}||| tt|t|kr9tt|t|kr9|||dd qd S )NFc                    r  r  r  r  r  r   r   rv  W  r  z+TestNPFunctions.test_in1d_3a.<locals>.checkTrE  r  )rF  r   r'  r  r   r  r  r   r  r   test_in1d_3aS  s   	
,zTestNPFunctions.test_in1d_3ac                    P   t t d fdd	} D ]\}}|||dd |||dd qd S )NFc                    r  r  r  r  r  rI  rr  rq  r  r   r   rv  i  r  z+TestNPFunctions.test_in1d_3b.<locals>.checkrH  Tr  )rK  r   r'  r  r   r  r   test_in1d_3be     	zTestNPFunctions.test_in1d_3bc                    s   t t d fdd	} D ]8\}}|||dd |||dd tt|t|krKtt|t|krK|||ddd |||ddd qd S )NFc                    s`   t | tr	t| } t |trt|}| |||} | |||}j||d|  d| d d S r  r  r  r  r0   rI  rr  rq  r  r   r   rv  z  s   

 z*TestNPFunctions.test_in1d_4.<locals>.checkrH  Tr0   rI  FF)rN  r   r'  r  r   r  r  r   r  r   test_in1d_4v  s   	,zTestNPFunctions.test_in1d_4c                 C     t }t|}tdg}tdg}|||}| |tdg |   | t |||dd W d    n1 s<w   Y  | t |||dd W d    n1 sXw   Y  | t |d|dd W d    n1 stw   Y  | t ||ddd W d    n1 sw   Y  t dd }| t |||d d W d    n1 sw   Y  | t |||d	d W d    d S 1 sw   Y  d S )
Nr   r~  Fr  Tc                 S   r3   NkindrB  r*   r+   r5  r   r   r   np_in1d_kind  r,  z6TestNPFunctions.test_in1d_errors.<locals>.np_in1d_kindr4  table)rN  r   r   r  ri  r  r  r   )r\  r  r  r*   r+   r   r7  r   r   r   test_in1d_errors  6   

"z TestNPFunctions.test_in1d_errorsc                  c   s   t tjt tjfV  tjdtjdt tjfV  tjdtjdt tjfV  tjdtjdt tjfV  dgt tjfV  t tjdgfV  dgdgfV  dgdgfV  ddgdgfV  g dddgfV  g dg dfV  ddgddgfV  dd	gtd
fV  dd	gttddfV  td	dd	dg dfV  td	g d} t
g dg dg dg}| |fV  t
d	|fV  | t
d	fV  t
d	t
d	fV  d|fV  | dfV  dV  t tj|fV  | t tjfV  ttjtjfD ]9}|tjtjhv rtj
g d|d}n|thv r't
g d}tj
g |d}||fV  ||fV  ||fV  qdD ]s}g dg d| fV  g dg d| fV  g dg d| fV  g d} | g d| fV  | g d| g d|  fV  t
g dt
g d| fV  t
g dt
g d| fV  t
ddgt
ddg| fV  qAt
dgt
dgfV  t
d d!gt
g d"fV  tjtjftjtjftjtjftjtjftjtjftjtjffD ]0\}}t|tj}tj
g d#|d}	|rtj
g d$|d}
n	tj
g d%|d}
|	|
fV  qtjd& D ]}tj
g dtd} tj
g d'|d}| |fV  || fV  q'd S )(N)r   r   r   )r   r   rJ  r   r~  r  r  r  r  r|  r  r  )r|  r  r  r  r  re  )r  r  r  r  )rz     r  r  r  )TFF)r   r  r  r  )r  r  r   r~  )r  r  r   r  )r|  r  r|  r  r  r  r  r  r  r|  r~  r   r|  r|  )r|  r|  r  )r|  r  r   r   r~  )r~  r  r  r  r   r|  TFr  )r   r   r   r   )ir      )r<  r   r  Z
AllInteger)r   r   r   r   )r	   r  r   r  r   r  r  r  rg  r  r  r  r6  r  r  uint16r  Zsignedinteger	typecodes)r*   r+   r   arZempty_arrayZmultZdtype1Zdtype2Zis_dtype2_signedr  r  r   r   r   _isin_arrays  s   









""&






zTestNPFunctions._isin_arraysc                    r  )Nc                    sX   | |}t | trt| } t |trt|} | |}j||d|  d| d d S r  r  r  r  r   r   rv     s   



 z*TestNPFunctions.test_isin_2.<locals>.check)rQ  r   r@  r  r   r  r   test_isin_2  r  zTestNPFunctions.test_isin_2c              	      s   t t d fdd	} D ]F\}}||| zt|}W n ty-   d}Y nw zt|}W n ty?   d}Y nw tt||krYtt||krY|||dd qd S )NFc                    \   | ||}t | trt| } t |trt|} | ||}j||d|  d| d d S r  r  r  r  r   r   rv       

 z+TestNPFunctions.test_isin_3a.<locals>.checkr   TrE  r  )rR  r   r@  r  rG  r   r  r\  rv  r*   r+   Zlen_alen_br   r  r   test_isin_3a  s&   	
$zTestNPFunctions.test_isin_3ac                    r*  )NFc                    rB  r  r  r+  r  r   r   rv  +  rC  z+TestNPFunctions.test_isin_3b.<locals>.checkrH  Tr  )rS  r   r@  r  r   r  r   test_isin_3b'  r-  zTestNPFunctions.test_isin_3bc              	      s   t t d fdd	} D ]X\}}|||dd |||dd zt|}W n ty6   d}Y nw zt|}W n tyH   d}Y nw tt||krktt||krk|||ddd |||ddd qd S )	NFc                    s`   | |||}t | trt| } t |trt|} | |||}j||d|  d| d d S r  r  r.  r  r   r   rv  <  s   

 z*TestNPFunctions.test_isin_4.<locals>.checkrH  Tr   r/  r0  )rT  r   r@  r  rG  r   r  rD  r   r  r   test_isin_48  s*   	$zTestNPFunctions.test_isin_4c                 C   r2  )
Nr   r~  Fr  Tc                 S   r3   r3  rO  r6  r   r   r   np_isin_kindh  r,  z6TestNPFunctions.test_isin_errors.<locals>.np_isin_kindr4  r8  )rT  r   r   r  ri  r  r  r   )r\  r  r  r*   r+   r   rI  r   r   r   test_isin_errorsU  r:  z TestNPFunctions.test_isin_errorsc                 C   st   t t}t t}t t}t t}tg d}tg d}|||}|||}|||}	||	|}
| ||
 d S )N)r|  r  r   r~  r  )r  r  r~  r  r  r   r|  )r   r=  r-   r  r@  r   r  ri  )r\  Znb_setxor1dZnb_intersect1dZ
nb_union1dZnb_setdiff1dr*   r+   c1Zaux1Zaux2c2r   r   r   test_setops_manywaysq  s   



z$TestNPFunctions.test_setops_manyways)NNFNr   r  )rZ  r[  r\  __doc__rX  rs  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-  r2  r7  r:  r<  rA  rB  rE  rH  rT  ra  re  rq  rx  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  staticmethodr  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,  r0  r2  r5  r7  r<  r>  rE  rG  rn  ro  rw  ry  r|  r}  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r&  r'  unittestZ
skipUnlessr   r+  r   r*  r/  r   r.  r3  skipr2  r5  r   r4  r9  r   r8  r;  r:  rK  rQ  rU  rV  r_  r`  ra  rb  rc  ro  rr  r  rx  ZskipIfr   rz  r{  r}  r~  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r   r"  r#  r$  r%  r&  r'  r(  r)  r,  r1  r9  r@  rA  rF  rG  rH  rJ  rM  __classcell__r   r   r]  r   rU    s
   -98' "!#
 F	WB()>#!5#'


eg"$"&
$



=




1
 V:*B(":
-,U@
! %-1E)N*E:37/3A.%$9 $2,:%BUrU  c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )TestNPMachineParametersz0
def foo():
    ty = np.%s
    return np.%s(ty)
c           	      G   sH   |}t dd|}|| }|| }|D ]}| t||t|| qd S r8  )r   ri  getattr)	r\  r  attrsr[   rj  rp  rr  rq  attrr   r   r   rv    s   zTestNPMachineParameters.checkc                 C   s<   |j }|j }| j||f }i }tt|ddt | |d S )Nz<string>execr  )rZ  templaterW  compileglobals)r\  ZbasefunctyZtystrZbasestrZfuncstrdctr   r   r   create_harcoded_variant  s   z/TestNPMachineParameters.create_harcoded_variantc                 C   s   t jt jt jt jg}d}|D ]}| t||d | t j|}| || q| t	}t
ddt}|d W d    n1 sBw   Y  d}| |t|j |   t
ddt}|t d W d    d S 1 spw   Y  d S )N)rt  ZepsnegZiexpZmacheprD  ZmaxexpZnegepZnexpZnmant	precision
resolutionZtinybitsr   Tr  rs  z(Unknown attribute 'machar' of type finfor  )r   rg  r  rh  r  rv  rs   r]  r  r   r   rt   r  r  r  r  r  )r\  r   rU  r[  hc_funcr  rp  rb  r   r   r   
test_finfo  s    

"z"TestNPMachineParameters.test_finfoc                 C   s   t jt jt jt jt jt jt jt jg}d}|D ]}| 	t
||d | t j
|}| 	|| q|   tddt
}|t d W d    d S 1 sMw   Y  d S )N)r}  rD  r`  r   Tr  r  )r   r6  r  r  r  r  r=  r  r  rv  rr   r]  r  r   r  )r\  r   rU  r[  ra  rp  r   r   r   
test_iinfo  s   
"z"TestNPMachineParameters.test_iinfoN)rZ  r[  r\  rX  rv  r]  rb  rc  r   r   r   r   rS    s    
rS  c                   @   rW  )TestRegistryImportsc                 C   sD   t d}t|\}}| d|  | jd| d| dd d S )Nz
            import numba
            import numpy as np
            @numba.njit
            def foo():
                np.array([1 for _ in range(1)])
            foo()
            print("OK")
        s   OK    z
--ERROR--

rs  )r   r   r  strip)r\  coderesulterrorr   r   r   test_unsafe_import_in_registry  s   	 z2TestRegistryImports.test_unsafe_import_in_registryN)rZ  r[  r\  rk  r   r   r   r   rd    s    rd  __main__r  )Nr   r   )rh   ri   F)r   r
  r  )r   )r   )r   N)NF)NTFN)NT)NN)r  )Nr  r   )Tr1  r0  )rc  r>  r  	functoolsr   r   textwrapr   numpyr   r  r   r   r   Z
numba.corer   Znumba.typedr	   r
   Znumba.np.numpy_supportr   Znumba.core.errorsr   Znumba.core.configr   Znumba.core.utilsr   Znumba.np.extensionsr   Znumba.tests.supportr   r   r   r   r   r   r   rP  r   r#   r&   r(   r-   r1   r7   r<   r=   rB   rD   rF   rJ   rL   rN   rU   rW   rY   r\   r]   r_   r`   ra   rb   rc   rd   rg   rk   rq   rr   rs   rt   rv   rx   ry   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r(  r)  r+  r-  r.  r5  r8  r:  r;  r=  r>  r@  rA  rC  rF  rK  rN  rQ  rR  rS  rT  rU  rS  rd  rZ  mainr   r   r   r   <module>   s  $                                                 D