
    Q3je                        d dl Zd dlZd dlZd dlmZ d dlmZm	Z	m
Z
 ej                  j                  dedgedgedgf      d        Zej                  j                  di ej                   fd	 ej"                  ej                         j$                  iej                   fd	 ej"                  ej                         j$                  dz   iej&                  fg      d
        Zej                  j                  dd ej*                  ddgej&                        iej&                  fd ej*                  ddgej                          ej*                  ddgej&                        fiej&                  fd ej*                  ddgej                          ej*                  ddgej                         fiej                   fd ej*                  ddgej,                        iej                   f ej*                  ddgej                          ej"                  ej                         j$                  dz   dej&                  fg      d        Zej                  j                  d ej*                  g ej&                         ej*                  g ej&                        fddej                   f ej*                  dgej&                        ddej                   f ej*                   ej"                  ej                         j$                  dz   gej0                        ddej&                  f ej*                  dgej                         d ej"                  ej                         j$                  dz   dej&                  f ej*                   ej"                  ej                         j$                  dz   gej0                        dddej&                  fg      d        Zej                  j                  dd	 ej"                  ej&                        j$                  dz   iedfd ej*                  ddgej6                        iedfdddgiedfg      d        Zej<                  j>                  ej<                  j@                  ej<                  jB                  ej<                  jD                  ej<                  jF                  ej<                  jH                  gZ%ej<                  jL                  ej<                  jN                  ej<                  jP                  ej<                  jR                  ej<                  jT                  ej<                  jV                  ej<                  jX                  ej<                  jZ                  gZ.e%e.z   Z/ej                  j                  de/      d        Z0ej                  j                  de%      d        Z1y)    N)assert_array_equal)_ensure_sparse_index_int32_object_dtype_isnan _smallest_admissible_index_dtypez
dtype, val   ac                     t        j                  |t         j                  gt         j                  |gg|       }t        j                  ddgddgg      }t        |      }t	        ||       y )NdtypeFT)nparraynanr   r   )r   valXexpected_maskmasks        K/DATA/.local/lib/python3.12/site-packages/sklearn/utils/tests/test_fixes.pytest_object_dtype_isnanr      sV    
3-"&&#/u=AHHudmdE];<Mq!Dt]+    zparams, expected_dtypemaxvalc                 $    t        di | |k(  sJ y)zlCheck the behaviour of `smallest_admissible_index_dtype` depending only on the
    `max_val` parameter.
    N r   paramsexpected_dtypes     r   ,test_smallest_admissible_index_dtype_max_valr      s     ,5f5GGGr   arrays   r
   )r   r   c                 $    t        di | |k(  sJ y)zCheck the behaviour of `smallest_admissible_index_dtype` using the passed
    arrays but without checking the contents of the arrays.
    Nr   r   r   s     r   >test_smallest_admissible_index_dtype_without_checking_contentsr!   *   s    \ ,5f5GGGr   T)r   check_contents)r   r"   r   c                 $    t        di | |k(  sJ y)zyCheck the behaviour of `smallest_admissible_index_dtype` using the dtype of the
    arrays but as well the contents.
    Nr   r   r   s     r   9test_smallest_admissible_index_dtype_by_checking_contentsr$   [   s    h ,5f5GGGr   zparams, err_type, err_msgz)is to large to be represented as np.int64z$Array dtype float64 is not supportedz#Arrays should be of type np.ndarrayc                 r    t        j                  ||      5  t        di |  ddd       y# 1 sw Y   yxY w)z-Check that we raise the proper error message.matchNr   )pytestraisesr   )r   err_typeerr_msgs      r   *test_smallest_admissible_index_dtype_errorr,      s)    $ 
xw	/(262 
0	/	/s   -6constructorc                 \     | t        j                  g dg dg            }t        |       y )N)      ?       @      @)r1   r0   r/   )r   r   r   )r-   As     r   test_ensure_sparse_index_int32r3      s"    BHHo?@AAq!r   c                 `   t        j                  t        d      5  ddgdt        j                  t        j
                        j                  dz   g}}d| j                  v r||}}t        j                  j                  ddg||ff      }t         | |             d d d        y # 1 sw Y   y xY w)	Nz	too larger&   r   r   r   cscr/   r0   )r(   r)   
ValueErrorr   iinfoint32max__name__spsparse	coo_arrayr   )r-   rowscolsr2   s       r   test_ensure_int32_raisesr@      s    	z	5Va"((!3!7!7!!;<dK(((t$DII#sdD\ :;";q>2 
6	5	5s   A?B$$B-)2numpyr   r(   scipyr;   sklearn.utils._testingr   sklearn.utils.fixesr   r   r   markparametrizeobjectfloatr   r8   r7   r9   int64r   r   int8r!   uint32r$   r6   float64	TypeErrorr,   r<   	csc_array	csr_arrayr=   
csc_matrix
csr_matrix
coo_matrixINDEX_CONSTRUCTORS	bsr_array
bsr_matrix	dia_array	dok_array	lil_array
dia_matrix
dok_matrix
lil_matrixNO_INDEX_TEST_CONSTRUCTORSSPARSE_CONSTRUCTORSr3   r@   r   r   r   <module>r^      s}      5  fc]UAJ'OP, Q, 	RXX
HBHHRXX&**	+RXX6
HBHHRXX&**Q.	/:HH  HBHHaV2884	5rxx@
 BHHaV2884BHHaV2884 HH	
 BHHaV2884BHHaV2884 HH	
 HBHHaV2773	4bhh?
 #"((Aq6:""((288,0014 HH	
;$'PHQ'PH 
 $288Bbhh7"BHH9UV"& HH	
  rxx2884MHH	
 #"((HBHHRXX$6$:$:Q$>#?ryyQ"& HH	
 #"((A3bhh7"&""((288,0014
 HH	
 #"((HBHHRXX$6$:$:Q$>#?ryyQ"&
 HH	
I,/`Ha/`H  xrxx)--127	
 xrxxAbjj9:2	

 QF	Y(MN 3! 3 IIIIIIIIIIII  IIIIIIIIIIIIIIII	  )+EE  (;<" ="
 (:;3 <3r   