
    ,|hH                         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y)	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                  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                  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                  j                  dg d      d        Zej                  j                  dg d      d        Zd Zej                  j                  dg d      d         Zej                  j                  dg d      d!        Zd" Zej                  j                  dg d      d#        Zej                  j                  dd	d$g      d%        Zd& Zej                  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                  j                  dg d      d(               Z!ej                  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-y	)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              y )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/test/engine/venv/lib/python3.12/site-packages/numpy/lib/tests/test_arraysetops.pytest_intersect1dzTestSetOps.test_intersect1d   s    HH\"HH_%XXi 1D11b! HH_%HH*+XXi 11b!2{2r23    c                      G d d      } |       }t        ||      }t        ||       t        g dg d      }t        |g d       y )Nc                       e Zd Zd Zy)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    yy|#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"   sA    	$ 	$ F!Q3")Y/3	*r&   c                     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        |
||	          y )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   HH\"HH\"1DN	2rXXi 1b!1R5"%1R5"% HH*+HH-.1T:	2rXXl#1b!1R5"%1R5"% HHlM23HHlN341DN	2rr177+r177+XXl#2qv&2qv& HHo78HHlN341T:	2rr177+r177+XXi 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              y )	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    HH\"HH_%XXi QN1b!HHYHHYXX()QN1b!HH\"HH\"XX()QN1b!2xB/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             y )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"   HHRL	88QC=88QF#2wy12A3	A >?A3	! <=B7GI1$MN2wx01A3 129gh1&MN?"8q!faVL	NAq678A#>?9gh1v&FGAq678a#@A9gh!Q&HIr&   zary, prepend, append, expectedr3   dtypeNrN   )r   r   r   rM   )      ?g      @g      "@c                     dj                  |      }t        t        |      5  t        |||       d d d        y # 1 sw Y   y xY w)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   sC    : 177A C0 	&!$&	& 	& 	&s	   :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                     t        j                  |||      }t        ||       |j                  |j                  k(  sJ y )NrX   )r   r   r   rU   )r   rY   r\   r]   r^   actuals         r$   test_ediff1d_scalar_handlingz'TestSetOps.test_ediff1d_scalar_handling   s<    : #)%,. 	VX&||x~~---r&   kind)Nsorttablec                    d }t        j                  |t        gdh      fd}t        j                  d      j	                  g d      }t        j
                  g dg dg d	g      } |||       d
dg}d} |||       t        j
                  d      } |||        |||        |||        |d|        ||d        |dd       dk7  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 |
      } ||        |||        |||        y )Nc                 l    t        j                  |      j                         j                         }| |v S )N)r   asarrayflattentolist)r   r    s     r$   
_isin_slowz(TestSetOps.test_isin.<locals>._isin_slow   s*    

1%%'..0A6Mr&   r   )otypesexcludedc                 L    t        | |      } | |      }t        ||       y )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   s   
	 LLTFaSI		% IIbM!!),HHlI|<=!Q V!Q HHQK!Q!Q!Q 	!Q!Q!Q 7? Aa#a#a# BHHbjj1 	8Ew5BJJ#62::..XXl%84&XX23((2U3Kk2.b+.k;7	8r&   c                 ~   dD ]>  }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        ||       A t        j                  dg      }t        j                  dg      }t        j                  dg      }t        |||      }t        ||       |dv rt        t        g g |      g        y y )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  sj     /	&DA$&A34BQD9Aq"%AaD45BQD9Aq"%JAaD!A$45BQD9Aq"%CDAD A4BQ%Aq"%I$$A+BQ%Aq"%&A4/0A34BQ%Aq"%)A+d23A9:BQ%Aq"%!Q A!Q$'A5%.)BQ%Aq"%_/	&b HHaSMHHaSMXXugAD!1b!>!tB6; "r&   c                     t        j                  g d      }t        j                  ddg      }t        j                  g d      }t        ||      }t        ||       y )N)r   r    r"   r   er"   r   r    r   r"   )TFTFFTFFr   rJ   s        r$   test_in1d_char_arrayzTestSetOps.test_in1d_char_arrayA  sG    HH=>HHc3Z XXKLAJ1b!r&   c           
         dD ]X  }t        j                  g d      }g d|z  }t        t        j                  t	        |||            t	        ||d|             Z |dv rdD ]  }t        j                  g dt         j
                        }g d|z  }t        j                  |t         j
                        }t        t        j                  t	        |||            t	        ||d|              y	y	)
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  s    
  	CDCDAD Aryya)>?#AqDAC	C >! GHHG"$**.$HHQbjj1"299T!QT-B#C#'1T#EGG "r&   c                    t        j                  d      j                  dd      }t        j                  dd      j                  dd      }t        j                  dd      j                  dd      }t        j                  g d      }t	        t        ||d|	      |       t	        t        ||d
|	      |       t	        t        ||d|	      |       t	        t        ||d
|	      |       y )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     IIaL  A&IIaO##Aq)1b!))"a0XX=>41DtD	41E%)+	 	46%)+	 	46%)+	r&   c                 Z   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	        ||       y)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     HH,BHH=HH^2884881>8T!QZ0299X.Q$0GHHH\2HH):XX/0AT*1b!r&   c           	         t        j                  ddg      }t        j                  g d      }t        j                  ddg      }t        |t        |||             t        t        j                  |      t        ||d|             y)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  sn     HHdE]#HH*+88UDM*8140	2299X.1T=	?r&   rf   c                    t         j                  j                  d      }|j                  ddd      }|j                  ddd      }t	        ||      }|j                  d      }|j                  d      }t        |t	        |||             y)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hh/05${Kd"KLr&   c                     t        j                  g dd      }|}t        j                  t              5  t        ||d       d d d        y # 1 sw Y   y xY w)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  sE    HHY&67]]:& 	%AG$	% 	% 	%s   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(  xrY t	        |t         j
                  k(  xr |t         j                  k(  |t         j                  k(  xr |t         j
                  k(  f      }|r3t        j                  t        d      5  t        |||	       d
d
d
       y
t        t        |||	      |       y
# 1 sw Y   y
xY w)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     ==1A1ABhh|62((>8C((=7C8867 Sbgg4&BHH"4bhh46RWW#42
 .
 |3GH *S#D)* * tC48(C* *s   D88E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        |||      |        y)	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3Axx 34@HtAqt4h?aqAxx 8EHtAqt4h?	@r&   c                     d g}t        j                  dgdz        }t        j                  dg      }t        j                  ||      }t        ||       y Nr   r<   Fr   r   r   r   r^   results        r$   test_in1d_first_array_is_objectz*TestSetOps.test_in1d_first_array_is_object  sG    fhhs2v88UG$c"68,r&   c                     d}t        j                  d gdz        }t        j                  dg      }t        j                  ||      }t        ||       y r   r   r   s        r$    test_in1d_second_array_is_objectz+TestSetOps.test_in1d_second_array_is_object  sE    hhvby!88UG$c"68,r&   c                     d g}t        j                  d gdz        }t        j                  dg      }t        j                  ||      }t        ||       y )Nr<   Tr   r   s        r$    test_in1d_both_arrays_are_objectz+TestSetOps.test_in1d_both_arrays_are_object  sG    fhhvby!88TF#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        ||       y )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  sr     XX#6(:;<hh	{"-hh	{2~R088TF#c"68,r&   c                    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
                  |             y )
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   hhay/hhay/88T4L)c"68,c$/6299X#67 hh(7#2hhh(7#2h88T4L)c"68,c$/6299X#67hh(7#2hhhay/88T5M*c"68,c$/6299X#6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           y
)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    hh'hh'(j$S{C ((.f=((.f=j$wGhh) 	=E((+59C88R%)<)<$=UKL
 c<g WWS,T:Fvv!';<WWS,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              y )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    HH_%HH*+XX()AqM1b! HHi+,HH_%XX()AqM1b!2wr2/r&   c                 @   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
                         y )	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    HH-.HH*+XXq!faO1b!IIbMIIbMXXr2haO1b!2yR01HHR#Yq"%++RYY7r&   c                     t        j                  g d      }t        j                  g d      }t        j                  ddg      }t        ||d      }t        ||       y )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  sH    HHYHHY88QF#1at4VX&r&   c                     t        j                  g d      }t        j                  g d      }t        t        ||      t        j                  dg             y )N)r   r    r"   )r   r    sr"   )r   r   r   r   r   s      r$   test_setdiff1d_char_arrayz$TestSetOps.test_setdiff1d_char_array^  s8    HH_%HH_%9Q?BHHcUO<r&   c                     t        j                  g d      }t        j                  g d      }t        ||      }t        ||      }t	        ||      }t        ||      }t        ||       y )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  sW    HH_%HH*+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$
+%'N10J& [[= 
)288	,				 
)288	,	)2::	.			 
,bgg	.				%@ .
&/.
& [[%
"((9BHH
-


"((<rxx
0
2 "((9BJJ
/
"((A3bjj
)

"((9BJJ
/
1 "((9BHH
-


"((<rxx
0
2 "((9BHH
-


"((=
1
3	
*.+*. [[V%<=:8 >:8x [[V%<=;< >;<z" [[V%<=G >G( [[V%<= >("  [[V%<=? >? [[VdF^4M 5M% [[WWbhhXXrwwXXryy!YY!XXrxx XXrxx 	

 [[V%<=D >
D. [[V%<=
@ >
@----8B =D0$8$'=
#r&   r   c                       e Zd Zd Zd Zd Zd Zej                  j                  dddg      d        Z
d	 Zd
 Zd Zd Zd Zy)
TestUniquec           	      l   d }g ddz  }g d}g d}g ddz  }t        j                  g dd      }g }|j                  t         j                  d          |j                  t         j                  d	          |j	                  d
       |j	                  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       y )0Nc                 >   d}|j                  d|      }t        |       }t        |||       |j                  d|      }t        | ddd      \  }}	t        |||       t        |	||       |j                  d|      }t        | ddd      \  }}	t        |||       t        |	||       |j                  d|      }t        | ddd      \  }}	t        |||       t        |	||       |j                  d|      }t        | ddd      \  }}
}t        |||       t        |
||       t        |||       |j                  d	|      }t        | ddd      \  }}
}t        |||       t        |
||       t        |||       |j                  d
|      }t        | ddd      \  }}
}t        |||       t        |
||       t        |||       |j                  d|      }t        | ddd      \  }}
}}t        |||       t        |
||       t        |||       t        |||       y )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)//."5C!T5%0DAqq!S)q"c*//"2B7C!UD%0DAqq!S)q"c*///26C!UE40DAqq!S)q!S)//"CRHCq$e4IAr2q!S)r2s+r2s+//"BBGCq$t4IAr2q!S)r2s+r1c*//"DbICq%t4IAr2q!S)r2s+r1c*// $79;=C"1dD$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   .	+` ""$"2%KKb) R\\,/0R\\*-._%%& 	-B!RB!RBb"b"a,	- XXc!fb!1XXc!fb!1"b"b!R( #XXd3q!9or*XXd3q!9or*"b"b!R( $299R=8X*>? % AY2s#Ad3
F2s#63' LLO#YYq6
F6288A;/ 14031T2151426889<V\\277+V\\277+V\\277+V\\277+ "&&#rvv&3RYYq\2&RYYqt4r6lCRYYq6VERYYq5F|D RVVVWS"&&%973;OPfgc26623 RYYq\2&RYYqt4r6lCRYYq6VERYYq5F|D mmE"]]<(#r}}\/JCPmmL)2==+FLRYYq\2&RYYqt4r6lCRYYq6VERYYq5F|D nnU#^^As#S"..C*@#FnnQ$bnnQ&<cBRYYq\2&RYYqt4r6lCRYYq6VERYYq5F|D FF8a<ffXRYYx("-RYYxd;b&\JRYYx=F|LRYYxt<r6lKr&   c                 d   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       y )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  sl    i!5!5v>i!5!5SzC=1	3 	bllFBIIbMBbllFBIIbMCr&   c                     d}g dg dg}t        j                  |      }t        t        |d      t        |d      |       t        t        |d      t        |d      |       y )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!  sR    .)$**S/6#A.wQ0GM6#A.wQ0GMr&   c                 ,   g }|j                  t        j                  d          |j                  t        j                  d          |j                  d       |j                  d       |j                  dt        fdt        fg       |j                  dt        fdt
        fg       |D ]  }| j                  |        d}t        j                  dt        j                  	      j                  d
d      j                  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      ||       y )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(  sO   R\\,/0R\\*-._%%&sCj3*-.sCj3,/0 	(E  '	( 7yy288,44R;@@FE4=4,7tD6$Q/=2xx$sDkD#;dLMD#;-(6$Q/=r&   r>  r   rO   c                 h    t        j                  g d      }t        ||      }t        |g d       y )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>  s'    HH-.ad#4.r&   c                    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 ]K  }t        |      }	||   dk(  rd|	|<   nd	|	|<   t        t        ||      t        j                  |	             M y )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   hhV277;$[qt48Nc3 	TZZ!2!234!783!.3!Q 013!. %[qt48Nc3 	TZZ!2!234!783-3-3- &.#e*% 	?D!%[NT{a'(t$'(t$vn4@!xxn=?	?r&   c                 `   t        j                  g dd      }t         j                  j                  |d      }t        j                  |      }t        j                  |dd      \  }}}d}t        |j                  |j                  |       t        |j                  |j                  |       y )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~    HHF"$EEq!$IIaL99QTFAqF166277C0166277C0r&   c                     d}dD ]C  }t        j                  dgdgg|      }t        j                  |d      }t        ||||z         E y )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  sP     ; 	/B2$b)A		!!$Aq!S2X.	/r&   c                 F   t        j                  g dg dg dg dg      j                  |      }d}t        j                  ddg      }t        t	        |      |j                  |      |       d}t        j                  g dg dg      }t        t	        |d      |j                  |      |       d}t        j                  g d	g d
g d	g d
g      }t        t	        |d      |j                  |      |       d}t        j                  ddgddggddgddggg      j                  |      }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      |       y )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   xx%%%' ( )/u 	
 71a&!6$<u)=sC6<676$Q/u1EsK69iIFG6$Q/u1EsK6QFF$FF$% & '-fUm 	 !Qa06&q163?$T48Nc3=49dC0?49d+>3!Q 0#6$T48Nc3=43<.?43<.>3 3S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             y )Nr   F)	equal_nan)r   r   r   r   r   )r   r   r.  not_unqs       r$   test_unique_nanequalsz TestUnique.test_unique_nanequals  s    HHaBFFBFFBFF34iil))A/3!RVV 567BHHa-H$I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RDN>, [[VaW-/ ./
"?H1/*:X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     sH    ? ?   ]	# ]	#@BK BKr&   