
    NgH                         d Z ddlZddlmZmZmZmZ ddlm	Z	m
Z
mZmZmZmZmZmZ ddlZ G d d          Z G d d          ZdS )	z-Test functions for 1D array set operations.

    N)assert_array_equalassert_equalassert_raisesassert_raises_regex)ediff1dintersect1dsetxor1dunion1d	setdiff1duniquein1disinc                      e Zd Zd Zd Zd Zd Zd Zej	        
                    d ej        g dej                  d	ej        d
f ej        g dej                   ej        g dej                  d	df ej        g dej                  ej        ej        dfg          d             Zej	        
                    d ej        g dej                  dd ej        g dej                  f ej        g dej                   ej        dgej                  d	 ej        g dej                  f ej        g dej                  dd ej        g dej                  f ej        g dej                  dd ej        g dej                  fg          d             Zej	        
                    dg d          d             Zej	        
                    dg d          d             Zd Zej	        
                    dg d          d              Zej	        
                    dg d          d!             Zd" Zej	        
                    dg d          d#             Zej	        
                    dd	d$g          d%             Zd& Zej	        
                    d'ej        ej        fej        ej        fej        ej         fej         ej        fej        ej        fej        ej        fg          ej	        
                    dg d          d(                         Z!ej	        
                    dg d          d)             Z"d* Z#d+ Z$d, Z%d- Z&d. Z'd/ Z(d0 Z)d1 Z*d2 Z+d3 Z,d4 Z-d	S )5
TestSetOpsc                    t          j        g d          }t          j        g d          }t          j        g d          }t          ||d          }t          ||           t          j        g d          }t          j        g d          }t          j        g d          }t          ||          }t          ||           t          g t          g g                      d S )N            r         r   r   )r   r   r   Tassume_unique)r   r   r   r   r   )r   r   r   r   r   r   r   )nparrayr   r   )selfabecceds         \/var/www/html/ai-engine/env/lib/python3.11/site-packages/numpy/lib/tests/test_arraysetops.pytest_intersect1dzTestSetOps.test_intersect1d   s    H\\\""H___%%Xiii  1D1111b!!! H___%%H***++Xiii  11b!!!2{2r2233333    c                      G d d          } |            }t          ||          }t          ||           t          g dg d          }t          |g d           d S )Nc                       e Zd Zd ZdS )4TestSetOps.test_intersect1d_array_like.<locals>.Testc                 *    t          j        d          S )Nr   )r   aranger   s    r$   	__array__z>TestSetOps.test_intersect1d_array_like.<locals>.Test.__array__%   s    y||#r&   N)__name__
__module____qualname__r-    r&   r$   Testr)   $   s#        $ $ $ $ $r&   r2   r   r   r   )r   r   )r   r2   r   ress       r$   test_intersect1d_array_likez&TestSetOps.test_intersect1d_array_like"   s    	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ DFF!Q3""")))YYY//3			*****r&   c                 Z   t          j        g d          }t          j        g d          }t          ||dd          \  }}}t          j        g d          }t          ||           t          ||         |           t          ||         |           t          j        g d          }t          j        g d          }t          ||d          \  }}}t          j        g d          }t          ||           t          ||         |           t          ||         |           t          j        g d	g d
g          }t          j        g dg dg          }t          ||dd          \  }}}t          j        ||j                  }t          j        ||j                  }	t          j        g d          }
t          |
||                    t          |
||	                    t          j        g dg dg          }t          j        g dg dg          }t          ||d          \  }}}t          j        ||j                  }t          j        ||j                  }	t          j        g d          }
t          |
||                    t          |
||	                    d S )Nr   r   r   r   )r   r   r      T)r   return_indices)r   r   r   )r   r   r   r   r   r   r   )r      r   r   r   r   r   r   )r9   )r   r   r   r8   )r   r:   r      )r   r   r   r8   )
      r:   	   )r   r8   r   r:   )r   r   r   r8   r8   )r   r   r:   r   r   )r   r   r   r   )r<   r=   r:   r   )r   r   r:   )r   r   r   r   unravel_indexshape)r   r   r    r"   i1i2eeefui1ui2eas              r$   test_intersect1d_indicesz#TestSetOps.test_intersect1d_indices.   s   H\\\""H\\\""1DNNN	2rXiii  1b!!!1R5"%%%1R5"%%% H***++H---..1T:::	2rXlll##1b!!!1R5"%%%1R5"%%% HlllMMM233HlllNNN3441DNNN	2rr17++r17++Xlll##2qv&&&2qv&&& Hooo788HlllNNN3441T:::	2rr17++r17++Xiii  2qv&&&2qv&&&&&r&   c                    t          j        g d          }t          j        g d          }t          j        g d          }t          ||          }t          ||           t          j        g d          }t          j        g d          }t          j        g d          }t          ||          }t          ||           t          j        g d          }t          j        g d          }t          j        g d          }t          ||          }t          ||           t          g t          g g                      d S )	Nr   r   )r   r   r   r3   )r8   r   r   )r   r   r   r   r   r8   )r   r:   r   r   )r8   r   r   r:   )r   r   r	   r   r   r   r    r!   r"   s        r$   test_setxor1dzTestSetOps.test_setxor1dU   s*   H\\\""H___%%Xiii  QNN1b!!!HYYYHYYYX((())QNN1b!!!H\\\""H\\\""X((())QNN1b!!!2xB//00000r&   c           	         t          j        g           }t          j        dg          }t          j        ddg          }t          g t          |                     t          dgt          |d                     t          dgt          |d                     t          ddgt          |dd                     t          g t          |                     t          dgt          |                     t          g dt          |d	d
                     t          g dt          |ddgd	dg                     t          dd
gt          |d
                     t          g dt          |d	dg                     t          d	dgt          |d	                     t          g dt          |ddg                     d S )Nr   r   r   )to_begin)to_end)rM   rN   )r   r   r>   r   r>   )r   r8   r   r   r:   r   r8   r:   )r   r   r:   )r   r8   r   )r   r   r   r   )r   	zero_elemone_elemtwo_elems       r$   test_ediff1dzTestSetOps.test_ediff1dm   s   HRLL	8QC==8QF##2wy11222A3	A > > >???A3	! < < <===B7GI1$M$M$MNNN2wx00111A3 1 1222999gh1&M&M&MNNN???"8q!faVLLL	N 	N 	NAq678A#>#>#>???999gh1v&F&F&FGGGAq678a#@#@#@AAA999gh!Q&H&H&HIIIIIr&   zary, prepend, append, expectedr3   dtypeNrN   )r   r   r   rM   )      ?g      @g      "@c                     d                     |          }t          t          |          5  t          |||           d d d            d S # 1 swxY w Y   d S )Nz dtype of `{}` must be compatiblearyrN   rM   )formatr   	TypeErrorr   )r   rY   prependappendexpectedmsgs         r$   !test_ediff1d_forbidden_type_castsz,TestSetOps.test_ediff1d_forbidden_type_casts   s    : 177AA C00 	& 	&!$& & & &	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   AAAzary,prepend,append,expectedi   i  )r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   )r   r   r   ra   c                 x    t          j        |||          }t          ||           |j        |j        k    sJ d S )NrX   )r   r   r   rU   )r   rY   r\   r]   r^   actuals         r$   test_ediff1d_scalar_handlingz'TestSetOps.test_ediff1d_scalar_handling   sO    : #)%,. . . 	VX&&&|x~------r&   kind)Nsorttablec                    d }t          j        |t          gdh          fd}t          j        d                              g d          }t          j        g dg dg d	g          } |||           d
dg}d} |||           t          j        d          } |||            |||            |||            |d|            ||d            |dd           dk    r&g }	 ||	|            |||	            ||	|	           t          t           j        t           j        fD ]}
dk    r|
t           j        k    r|
t           j        t           j        hv rt          j        g d|
          }n |
t          hv rt          j        g d          }t          j        g |
          } |||            |||            |||           d S )Nc                 z    t          j        |                                                                          }| |v S )N)r   asarrayflattentolist)r   r    s     r$   
_isin_slowz(TestSetOps.test_isin.<locals>._isin_slow   s0    
1%%''..00A6Mr&   r   )otypesexcludedc                 d    t          | |          } | |          }t          ||           d S )Nre   )r   r   )r   r    xy	isin_slowre   s       r$   assert_isin_equalz/TestSetOps.test_isin.<locals>.assert_isin_equal   s<    Q%%%A	!QAq!$$$$$r&      r   r   r   )r<         )r   r   r   )      !   )r>   r:   )r   r8   )r>   r   r   r   r8   rg   rT   TFF)r   	vectorizeboolr+   reshaper   int64float64)r   re   rm   ru   r   r    r"   dfrr   rU   arempty_arrayrt   s    `           @r$   	test_isinzTestSetOps.test_isin   sr   
	 	 	 LTFaSIII		% 	% 	% 	% 	% 	% IbMM!!))),,HlllIII|||<==!Q V!Q HQKK!Q!Q!Q 	!Q!Q!Q 7?? Aa###a###a### BHbj1 	8 	8Ew5BJ#6#62:...Xlll%8884&X22233(2U333Kk2...b+...k;7777	8 	8r&   c                    dD ]q}g d}g d|z  }t          j        g d          }t          ||d|          }t          ||           d|d<   t          j        g d	          }t          ||d|          }t          ||           d
\  |d<   |d<   t          j        g d          }t          ||d|          }t          ||           t          j        g d          }g d|z  }g d}t          |||          }t          ||           |g d|z  z   }g d}t          |||          }t          ||           t          j        g d          }t          j        g d|z            }t          j        g d          }t          |||          }t          ||           t          j        g d          }t          j        g d|z            }t          j        g d          }t          |||          }t          ||           t          j        ddg          }t          j        ddg|z            }t          j        ddg          }t          |||          }t          ||           st          j        dg          }t          j        dg          }t          j        dg          }t          |||          }t          ||           |dv r"t          t          g g |          g            d S d S )Nr   r<   r   r   TFTTTr   re   r:   r   )FFTT)r   r:   r   )TFTFr   r   r   r   r   r   r   r   r   r   r   r   r   r   rw   )FTFTTTTTTFTFFFrq   )r   r   r   )TTTTTTTTTTTFTT)r   r   r   r   r   )r   r   r   r   r   r   )TFTTTr   r   F>   Nrf   r   r   r   r   )r   re   multr   r    r!   r"   s          r$   	test_in1dzTestSetOps.test_in1d  sU     /	& /	&DA$&A33344BQD999Aq"%%%AaD44455BQD999Aq"%%%JAaD!A$44455BQD999Aq"%%%CCCDDA		D A4 4 4BQ%%%Aq"%%%III$$A+ + +BQ%%%Aq"%%%&&A4/00A33344BQ%%%Aq"%%%))A+++d233A999::BQ%%%Aq"%%%!Q  A!Q$''A5%.))BQ%%%Aq"%%%%HaSMMHaSMMXugAD!!!1b!!!>!!tB666;;;;; "!r&   c                     t          j        g d          }t          j        ddg          }t          j        g d          }t          ||          }t          ||           d S )N)r   r    r"   r   er"   r   r    r   r"   )TFTFFTFFr   rJ   s        r$   test_in1d_char_arrayzTestSetOps.test_in1d_char_arrayA  sd    H===>>Hc3Z  XKKKLLAJJ1b!!!!!r&   c           
         dD ]b}t          j        g d          }g d|z  }t          t          j        t	          |||                    t	          ||d|                     c|dv rdD ]}t          j        g dt           j                  }g d|z  }t          j        |t           j                  }t          t          j        t	          |||                    t	          ||d|                     d	S d	S )
zTest in1d's invert parameterr   r   rw   rq   Tinvertre   >   Nrf   rT   N)r   r   r   r   r   float32)r   re   r   r   r    s        r$   test_in1d_invertzTestSetOps.test_in1d_invertJ  sG   
  	C 	CDCCCDDA		D Arya)>)>)>??#AqDAAAC C C C >!! G GHGGG"$*. . .II$HQbj111"29T!QT-B-B-B#C#C#'1T#E#E#EG G G G "!G Gr&   c                 .   t          j        d                              dd          }t          j        dd                              dd          }t          j        dd                              dd          }t          j        g d          }t	          t          ||d|	          |           t	          t          ||d
|	          |           t	          t          ||d|	          |           t	          t          ||d
|	          |           d S )Nr8   r   r   r>   ?   ry   )FFFTTTTr   F)r   r+   r   r   r   r   )r   re   r   r    long_br!   s         r$   test_in1d_ravelzTestSetOps.test_in1d_ravel_  s:    IaLL  A&&IaOO##Aq))1b!!))"a00X===>>41DtDDD	 	 	41E%)+ + +	 	 	 	46%)+ + +	 	 	 	46%)+ + +	 	 	 	 	r&   c                 `   t          j        g dt           j                  }t          j        g dt           j                  }t          j        g dt                    }t	          |t          ||                     t	          t          j        |          t          ||d                     t          j        g dt           j                  }t          j        g dt           j                  }t          j        g d	          }t          ||d
          }t	          ||           dS )z(Hit the standard isin code with integers)r   r   r   r   r   r       eArT   )r   r   r   r   )r   r   r   r   r   r   r   Tr   r   )r   r   r   r   r   r   r   r   N)r   r   r   r   r   r   r   )r   r   r    r^   r!   r"   s         r$   !test_in1d_hit_alternate_algorithmz,TestSetOps.test_in1d_hit_alternate_algorithmt  s    H,,,BH===H^^^284448111>>>8T!QZZ00029X..Q$0G0G0GHHHH\\\222H))):::X///00AT***1b!!!!!r&   c           	      0   t          j        ddg          }t          j        g d          }t          j        ddg          }t          |t          |||                     t          t          j        |          t          ||d|                     dS )z&Test that in1d works for boolean inputTF)FFFrq   r   N)r   r   r   r   r   )r   re   r   r    r^   s        r$   test_in1d_booleanzTestSetOps.test_in1d_boolean  s     HdE]##H***++8UDM**814000	2 	2 	229X..1T===	? 	? 	? 	? 	?r&   rf   c                 X   t           j                            d          }|                    ddd          }|                    ddd          }t	          ||          }|                    d          }|                    d          }t          |t	          |||                     dS )z(Test that in1d works for timedelta inputr   d   r<   )sizetimedelta64[s]rq   N)r   randomRandomStaterandintr   astyper   )r   re   rstater   r    trutha_timedeltab_timedeltas           r$   test_in1d_timedeltazTestSetOps.test_in1d_timedelta  s     &&q))NN1cN++NN1cN++Q

hh/00hh/005${Kd"K"K"KLLLLLr&   c                     t          j        g dd          }|}t          j        t                    5  t          ||d           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   rT   rg   rq   )r   r   pytestraises
ValueErrorr   r   r   r    s      r$   test_in1d_table_timedelta_failsz*TestSetOps.test_in1d_table_timedelta_fails  s    HYYY&6777]:&& 	% 	%AG$$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   AAAzdtype1,dtype2c                    t          j        |t           j                  }t          j        g d|          }|rt          j        g d|          }nt          j        g d|          }t          j        g d          }|dk    oLt	          |t           j        k    o|t           j        k    |t           j        k    o|t           j        k    f          }|rHt          j        t          d          5  t          |||	           d
d
d
           d
S # 1 swxY w Y   d
S t          t          |||	          |           d
S )z7Test that in1d works as expected for mixed dtype input.)r   r   r   r   rT   )ir      )r   r      )TTFFrg   zexceed the maximum)matchrq   N)r   
issubdtypesignedintegerr   anyint8int16r   r   RuntimeErrorr   r   )	r   dtype1dtype2re   is_dtype2_signedar1ar2r^   expect_failures	            r$   test_in1d_mixed_dtypez TestSetOps.test_in1d_mixed_dtype  s    =1ABBh|||6222 	8(>>>888CC(===777C866677 Sbg4&BH"4bh46RW#42
 . .
  	D|3GHHH * *S#D))))* * * * * * * * * * * * * * * * * * tC4888(CCCCCs   1DDDc                    t           j        d         D ]}t          j        g dt                    }t          j        g d|          }t          j        g dt                    }t	          t          |||          |           ||}}t          j        g dt                    }t	          t          |||          |           dS )	z4Test that in1d works as expected for bool/int input.
AllIntegerr}   rT   r   r   r   r   )FTTrq   )TTTTN)r   	typecodesr   r   r   r   )r   re   rU   r   r    r^   s         r$   test_in1d_mixed_booleanz"TestSetOps.test_in1d_mixed_boolean  s     \,/ 	@ 	@E---T:::AU333Ax 3 3 34@@@HtAqt444h???aqAx 8 8 8EEEHtAqt444h????	@ 	@r&   c                     d g}t          j        dgdz            }t          j        dg          }t          j        ||          }t          ||           d S Nr   r<   Fr   r   r   r   r^   results        r$   test_in1d_first_array_is_objectz*TestSetOps.test_in1d_first_array_is_object  sV    fhs2v8UG$$c""68,,,,,r&   c                     d}t          j        d gdz            }t          j        dg          }t          j        ||          }t          ||           d S r   r   r   s        r$    test_in1d_second_array_is_objectz+TestSetOps.test_in1d_second_array_is_object  sT    hvby!!8UG$$c""68,,,,,r&   c                     d g}t          j        d gdz            }t          j        dg          }t          j        ||          }t          ||           d S )Nr<   Tr   r   s        r$    test_in1d_both_arrays_are_objectz+TestSetOps.test_in1d_both_arrays_are_object  sV    fhvby!!8TF##c""68,,,,,r&   c                 $   t          j        dt          fdt          fg          }t          j        dg|          }t          j        dgdz  |          }t          j        dg          }t          j        ||          }t          ||           d S )Nfield1field2)r   NrT   r<   T)r   rU   intobjectr   r   r   )r   dtr   r   r^   r   s         r$   +test_in1d_both_arrays_have_structured_dtypez6TestSetOps.test_in1d_both_arrays_have_structured_dtype  s     X#6(:;<<h	{"---h	{2~R0008TF##c""68,,,,,r&   c                 V   t          j        ddgt                    }t          j        ddgt                    }t          j        ddg          }t          j        ||          }t	          ||           t          j        ||d          }t	          |t          j        |                     t          j        g dt                    }|d d         }t          j        g dt                    }|d d         }t          j        ddg          }t          j        ||          }t	          ||           t          j        ||d          }t	          |t          j        |                     t          j        g dt                    }|d d         }t          j        ddgt                    }t          j        dd	g          }t          j        ||          }t	          ||           t          j        ||d          }t	          |t          j        |                     d S )
Nr   r   rT   Tr   )r   )r   r   r   rO   )r   r   r   r   F)r   r   r   r   r   r   r   s        r$   'test_in1d_with_arrays_containing_tuplesz2TestSetOps.test_in1d_with_arrays_containing_tuples  s   hay///hay///8T4L))c""68,,,c$///629X#6#6777 h(((777#2#hh(((777#2#h8T4L))c""68,,,c$///629X#6#6777h(((777#2#hhay///8T5M**c""68,,,c$///629X#6#677777r&   c                    t          j        g d          }t          j        g d          }t          t          t          ||d           t          j        g dt
                    }t          j        g dt
                    }t          t          t          ||d           t           j        t           j        fD ]}t          j        g d|          }t          j        d	t          j        |          j	        g|          }t          t          t          ||d           t          j        ||d
          }t          |dgdgdz  z              t          j        ||d          }t          |dgdgdz  z              d
S )z&Test that in1d raises expected errors.)r   r   r   r   r   )r   r   r8   r:   r<   	quicksortrq   )r   r   r   r    r   rT   rg   )rO   r   r   r   r   rO   NTFr   rf   )r   r   r   r   r   r   int32r   iinfomaxr   r   )r   r   r   obj_ar1obj_ar2rU   overflow_ar2r   s           r$   test_in1d_errorszTestSetOps.test_in1d_errors  s    h''h'''((j$S{CCCC (...f===(...f===j$wGGGGh) 	= 	=E(+++5999C8R%)<$=UKKKL
 c<g    WS,T:::Fvv!';<<<WS,V<<<Fvv!';<<<<'	= 	=r&   c                    t          j        g d          }t          j        g d          }t          j        g d          }t          ||          }t          ||           t          j        g dg dg          }t          j        g d          }t          j        g d          }t          ||          }t          ||           t          g t          g g                      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   r   r   r   r   )r   r   r
   r   )	r   r   r    r!   r"   rr   rs   ezzs	            r$   test_union1dzTestSetOps.test_union1d3  s    H___%%H***++X((())AqMM1b!!! Hiii+,,H___%%X((())AqMM1b!!!2wr2/////r&   c                 Z   t          j        g d          }t          j        g d          }t          j        ddg          }t          ||          }t          ||           t          j        d          }t          j        d          }t          j        ddg          }t          ||          }t          ||           t          g t          g g                      t          j        dt           j                  }t          t          |g           j        t           j                   d S )	N)r8   r   r   r   r   r   r   r   r   r8   r         rx   r1   )r   r   r   r   r+   uint32r   rU   rJ   s        r$   test_setdiff1dzTestSetOps.test_setdiff1dE  s    H---..H***++Xq!faOO1b!!!IbMMIbMMXr2haOO1b!!!2yR00111HR##Yq"%%+RY77777r&   c                     t          j        g d          }t          j        g d          }t          j        ddg          }t          ||d          }t          ||           d S )N)r   r   r   )r   r   r   r   r   Tr   )r   r   r   r   )r   r   r    r^   rc   s        r$   test_setdiff1d_uniquez TestSetOps.test_setdiff1d_uniqueW  se    HYYYHYYY8QF##1at444VX&&&&&r&   c                     t          j        g d          }t          j        g d          }t          t          ||          t          j        dg                     d S )N)r   r    r"   )r   r    sr"   )r   r   r   r   r   s      r$   test_setdiff1d_char_arrayz$TestSetOps.test_setdiff1d_char_array^  sP    H___%%H___%%9Q??BHcUOO<<<<<r&   c                     t          j        g d          }t          j        g d          }t          ||          }t          ||          }t	          ||          }t          ||          }t          ||           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    c1aux1aux2c2s          r$   test_manywayszTestSetOps.test_manywaysc  sy    H___%%H***++a^^1a  q!}}tT""2r"""""r&   ).r.   r/   r0   r%   r5   rH   rK   rS   r   markparametrizer   r   r   nanr   r   r`   r   r   r   rd   r   r   r   r   r   r   r   r   r   uint8uint16r   r   r   r   r   r   r   r   r   r   r   r   r   r1   r&   r$   r   r      s~       4 4 4$
+ 
+ 
+%' %' %'N1 1 10J J J& [= 
)))28	,	,	,				 
)))28	,	,	,	)))2:	.	.	.			 
,,,bg	.	.	.				%@  .
& 
&/ .
& [%
"(999BH
-
-
-


"(<<<rx
0
0
0
2 "(999BJ
/
/
/
"(A3bj
)
)
)

"(999BJ
/
/
/
1 "(999BH
-
-
-


"(<<<rx
0
0
0
2 "(999BH
-
-
-


"(===
1
1
1
3	
 *. .+ *. [V%<%<%<==:8 :8 >=:8x [V%<%<%<==;< ;< >=;<z" " " [V%<%<%<==G G >=G( [V%<%<%<==  >=(" " "  [V%<%<%<==? ? >=? [VdF^44M M 54M% % % [WbhXrwXry!Y!Xrx Xrx 	

 
 [V%<%<%<==D D >=
 
D. [V%<%<%<==
@ 
@ >=
@- - -- - -- - -- - -8 8 8B =  =  =D0 0 0$8 8 8$' ' '= = =
# # # # #r&   r   c                       e Zd Zd Zd Zd Zd Zej        	                    dddg          d             Z
d	 Zd
 Zd Zd Zd ZdS )
TestUniquec           	         d }g ddz  }g d}g d}g ddz  }t          j        g dd          }g }|                    t           j        d                    |                    t           j        d	                    |                    d
           |                    d           |D ]<}t          j        ||          }	t          j        ||          }
 ||	|
||||           =d}t          j        t          |          |          }	||	d d <   t          j        t          |          |          }
||
d d <    ||	|
||||           ddg}t          j        t          t          ||                    |          }	t          j        t          t          ||                    |          }
 ||	|
||||           g d}	t          t          j        |	          ddg           g d}g d}g d}t          |          }t          ||           t          |d          \  }}t          ||           t          ||           t          j        d          }d|d<   t          j        |d          \  }}t          |t          j        d                     g }t          j        |d          d         }t          j        |d          d         }t          j        |dd          dd          \  }}t          |j        t           j                   t          |j        t           j                   t          |j        t           j                   t          |j        t           j                   dt           j        dt           j        g}ddt           j        g}g d}g d}g d }t          t          j        |          |           t          t          j        |d          ||f           t          t          j        |d          ||f           t          t          j        |d!          ||f           d"t           j        d#t%          d$t           j                  t%          dt           j                  g}d#d"t%          d$t           j                  g}g d%}g d&}g d'}t          t          j        |          |           t          t          j        |d          ||f           t          t          j        |d          ||f           t          t          j        |d!          ||f           t          j        d(          }t          j        d)          |t          j        d*          |g}t          j        d*          t          j        d)          |g}g d}g d}g d }t          t          j        |          |           t          t          j        |d          ||f           t          t          j        |d          ||f           t          t          j        |d!          ||f           t          j        d(          }t          j        dd+          |t          j        dd,          |g}t          j        dd,          t          j        dd+          |g}g d}g d}g d }t          t          j        |          |           t          t          j        |d          ||f           t          t          j        |d          ||f           t          t          j        |d!          ||f           t           j        gd-z  }t           j        g}d.g}g d/}d-g}t          t          j        |          |           t          t          j        |d          ||f           t          t          j        |d          ||f           t          t          j        |d!          ||f           d S )0Nc                 `   d}|                     d|          }t          |           }t          |||           |                     d|          }t          | ddd          \  }}	t          |||           t          |	||           |                     d|          }t          | ddd          \  }}	t          |||           t          |	||           |                     d|          }t          | ddd          \  }}	t          |||           t          |	||           |                     d|          }t          | ddd          \  }}
}t          |||           t          |
||           t          |||           |                     d	|          }t          | ddd          \  }}
}t          |||           t          |
||           t          |||           |                     d
|          }t          | ddd          \  }}
}t          |||           t          |
||           t          |||           |                     d|          }t          | ddd          \  }}
}}t          |||           t          |
||           t          |||           t          |||           d S )Nzcheck {0} failed for type {1}valuesreturn_indexTFreturn_inversereturn_countszreturn_index and return_inversezreturn_index and return_countsz return_inverse and return_countsz.return_index, return_inverse and return_counts)rZ   r   r   )r   r    rA   rB   r"   r   base_msgr_   vjj1j2j3s                r$   	check_allz,TestUnique.test_unique_1d.<locals>.check_allr  s   6H//(B//Cq		Aq!S)))//."55C!T5%00DAqq!S)))q"c***//"2B77C!UD%00DAqq!S)))q"c***///266C!UE400DAqq!S)))q!S)))//"CRHHCq$e44IAr2q!S)))r2s+++r2s+++//"BBGGCq$t44IAr2q!S)))r2s+++r1c***//"DbIICq%t44IAr2q!S)))r2s+++r1c***// $79;= =C"1dD$77MAr2rq!S)))r2s+++r2s+++r1c*****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   AllFloatdatetime64[D]timedelta64[D]O) i)      ?              ?      r   r  r  )r   r   r  r   r3   )r   r   r   r   r   r   T)r	  r   r  .)r  r   )r  r	  g       @rV   )r   r   r   )r   r   r   r   )r   r   r   )r
  y       @      y      ?      ?        )r   r   r   )r   r   r   r   r   )r   r   r   natz
2020-12-26z
2020-12-24Dhr   r   r   )r   multiplyextendr   r]   r   emptylenlistzipr   r   	chararrayzerosr   rU   intpr   complex
datetime64timedelta64)r   r  r   r    rA   rB   r"   typesr   aabbunqinva1a2a2_inva1_idxa3_idxa3_invuaua_idxua_invua_cntr  all_nanss                            r$   test_unique_1dzTestUnique.test_unique_1dp  s   .	+ .	+ .	+` "!!"$LL\\"""2%Kb)) R\,/000R\*-..._%%%%&&& 	- 	-B!RB!RBIb"b"a,,,, Xc!ffb!!111Xc!ffb!!111	"b"b!R((( #Xd3q!99oor**Xd3q!99oor**	"b"b!R((( $##29R==8X*>??? %$$ii   AYY2s###Ad333
F2s###63''' LOO#Yq666
F628A;;/// 1400031T2221514268 8 889<V\27+++V\27+++V\27+++V\27+++ "&#rv&3RYq\\2&&&RYqt444r6lCCCRYq666VEEERYq555F|DDD RVVWS"&%9%973;O;OPfgc26223 RYq\\2&&&RYqt444r6lCCCRYq666VEEERYq555F|DDD mE""]<((#r}\/J/JCPmL))2=+F+FLRYq\\2&&&RYqt444r6lCCCRYq666VEEERYq555F|DDD nU##^As##S".C*@*@#FnQ$$bnQ&<&<cBRYq\\2&&&RYqt444r6lCCCRYq666VEEERYq555F|DDD F8a<fXRYx(("---RYxd;;;b&\JJJRYx===F|LLLRYxt<<<r6lKKKKKr&   c                 l   t          t          | j        t                     t          t          | j        dt          fdt          fg           t          t
          j        t          t          j        d          d           t          t
          j        t          t          j        d          d           d S )Nr   r    r<   r   axis)	r   r[   _run_axis_testsr   r   r   	AxisErrorr   r+   r,   s    r$   test_unique_axis_errorsz"TestUnique.test_unique_axis_errors  s    i!5v>>>i!5SzC=1	3 	3 	3 	blFBIbMMBBBBblFBIbMMCCCCCCr&   c                     d}g dg dg}t          j        |          }t          t          |d          t          |d          |           t          t          |d          t          |d          |           d S )NzUnique failed on list of listsr   r   r   r   r=  r   )r   rj   r   r   )r   r_   inpinp_arrs       r$   test_unique_axis_listz TestUnique.test_unique_axis_list!  s    .yy)))$*S//6#A...wQ0G0G0GMMM6#A...wQ0G0G0GMMMMMr&   c                    g }|                     t          j        d                    |                     t          j        d                    |                    d           |                    d           |                    dt          fdt          fg           |                    dt          fdt
          fg           |D ]}|                     |           d}t          j        dt          j        	          	                    d
d          
                    t                    }t          j        ddgddggt          	          }t          t          |d          ||           d}t          j        ddgddgddgddgg          }t          j        ddgg          }t          t          |d          ||           d S )Nr   r  r  r  r   r    z&Non-bitwise-equal booleans test failedr<   rT   rO   r   FTr   r=  z"Negative zero equality test failedg       r  )r   r   r   r]   r   floatr@  r+   r  r   viewr   r   r   r   )r   r+  rU   r_   datar   s         r$   test_unique_axiszTestUnique.test_unique_axis(  s   R\,/000R\*-..._%%%%&&&sCj3*-...sCj3,/000 	( 	(E  ''''6y28,,,44R;;@@FFE4=4,7tDDD6$Q///===2x$sDkD#;dLMMD#;-((6$Q///=====r&   r>  r   rO   c                 x    t          j        g d          }t          ||          }t          |g d           d S )N)r   r   r   r   r   r   r   r   r=  r7   r   r   r   r   )r   r>  rr   uniqs       r$   test_unique_1d_with_axisz#TestUnique.test_unique_1d_with_axis>  sD    H---..ad###4.....r&   c                 Z   t          j        dt           j                  }t          |dddd          \  }}}}t	          |j        |j                   t          |t          j        d                     t          |t          j        dg                     t          |t          j        ddg                     t          |t          j        dg                     t          |d	ddd          \  }}}}t	          |j        |j                   t          |t          j        d                     t          |t          j        g                      t          |t          j        g                      t          |t          j        g                      d
}t          j        |          }t          t          |                    D ]Z}t          |          }	||         dk    rd|	|<   nd	|	|<   t          t          ||          t          j        |	                     [d S )N)r   r   )r@   rU   r   Tr>  r  r	  r
  )r   r   )r@   r   r   )r   r   r   r   r   r   r   r=  )r   r!  r   r   r   rU   r   r   ranger"  r#  )
r   single_zerorO  idxr/  cntr@   multiple_zerosr>  expected_shapes
             r$   test_unique_axis_zerosz!TestUnique.test_unique_axis_zerosD  s   hV27;;;$[qt48N N Nc3 	TZ!23334!7!7!78883!...3!Q 0 01113!... %[qt48N N Nc3 	TZ!23334!7!7!78883---3---3--- &...#e**%% 	? 	?D!%[[NT{a'(t$$'(t$vn4@@@!xn===? ? ? ?	? 	?r&   c                 D   t          j        g dd          }t           j                            |d          }t          j        |          }t          j        |dd          \  }}}d}t          |j        |j        |           t          |j        |j        |           d S )N)@   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  rT   r   T)r  r
  z6Unique returned different results when asked for index)r   r   mamasked_equalr   r   rK  mask)r   rr   rs   r  v2r  r"   r_   s           r$   test_unique_maskedzTestUnique.test_unique_maskedh  s    HFFF"$ $ $Eq!$$IaLL9QTFFFAqF1627C0001627C00000r&   c                     d}dD ]E}t          j        dgdgg|          }t          j        |d          }t          ||||z             Fd S )Nz*sort order incorrect for integer type '%s'bhilqrO   r   r=  rN  )r   fmtr   r   r    s        r$    test_unique_sort_order_with_axisz+TestUnique.test_unique_sort_order_with_axisu  sh     ; 	/ 	/B2$b))A	!!$$$Aq!S2X....	/ 	/r&   c                    t          j        g dg dg dg dg                              |          }d}t          j        ddg          }t          t	          |          |                    |          |           d}t          j        g dg dg          }t          t	          |d          |                    |          |           d}t          j        g d	g d
g d	g d
g          }t          t	          |d          |                    |          |           d}t          j        ddgddggddgddggg                              |          }t          j        |ddgd          }t          t	          |d          ||           t	          |dddd          \  }}}}	d}t          ||         ||           d}t          ||         |           d}t          |	t          j        ddg          |           t	          |dddd          \  }}}}	d}t          |d d |f         |           d}t          |d d |f         |           d}t          |	t          j        g d          |           d S )N)r   r   r   r   )r   r   r   r   z&Unique with 1d array and axis=0 failedr   r   z&Unique with 2d array and axis=0 failedr=  z&Unique with 2d array and axis=1 failed)r   r   r   rD  z&Unique with 3d array and axis=2 failedr   TrR  z-Unique's return_index=True failed with axis=0z/Unique's return_inverse=True failed with axis=0z.Unique's return_counts=True failed with axis=0z-Unique's return_index=True failed with axis=1z/Unique's return_inverse=True failed with axis=1z.Unique's return_counts=True failed with axis=1)r   r   r   )r   r   r   r   r   take)
r   rU   rK  r_   r   data3drO  rU  r/  rV  s
             r$   r@  zTestUnique._run_axis_tests~  s   x%%%' ( ( )/u 	
 71a&!!6$<<u)=)=sCCC6<<<6776$Q///u1E1EsKKK6999iiiIIIFGG6$Q///u1E1EsKKK6QFF$FF$% & & '-fUmm 	 !Qa0006&q11163???$T48N N Nc3=49dC000?49d+++>3!Q 0 0#666$T48N N Nc3=43<...?43<...>3 3 3S99999r&   c           	         t          j        ddt           j        t           j        t           j        g          }t          j        |          }t          j        |d          }t	          |t          j        dt           j        g                     t	          |t          j        dt           j        t           j        t           j        g                     d S )Nr   F)	equal_nan)r   r   r   r   r   )r   r   r.  not_unqs       r$   test_unique_nanequalsz TestUnique.test_unique_nanequals  s    HaBFBFBF344ill)A///3!RV 5 56667BHa-H$I$IJJJJJr&   N)r.   r/   r0   r;  rB  rG  rL  r   r   r   rP  rY  r`  rd  r@  rk  r1   r&   r$   r  r  n  s        gL gL gLRD D DN N N> > >, [VaW--/ / .-/
"? "? "?H1 1 1/ / /*: *: *:XK K K K Kr&   r  )__doc__numpyr   numpy.testingr   r   r   r   numpy.lib.arraysetopsr   r   r	   r
   r   r   r   r   r   r   r  r1   r&   r$   <module>rp     s?       ? ? ? ? ? ? ? ? ? ? ? ?                    ]	# ]	# ]	# ]	# ]	# ]	# ]	# ]	#@BK BK BK BK BK BK BK BK BK BKr&   