
    Q3j8L                     6   d Z ddlZddlZddlZddlZddlZddlZ	 ddlZ	ddlmZ ddlmZ d ej                   d      z  dk(  Z ej$                         dv Z eej(                        Z eej,                        Z eej(                        Z eej,                        Zej4                  j6                  ej4                  j8                  gZej4                  j<                  ej4                  j>                  gZ ej4                  jB                  ej4                  jD                  gZ#ej4                  jH                  ej4                  jJ                  gZ&ej4                  jN                  ej4                  jP                  gZ)ej4                  jT                  ej4                  jV                  gZ,ej4                  jZ                  ej4                  j\                  gZ/	 dd	l0m1Z1 d
Z2d Z3d0dZ4e ed      k  Z5e ed      k  Z6e ed      k\  r!ej4                  jn                  jp                  Z9nd Z9e ed      k\  rd Z:d Z;nd Z<d Z=d Z>d Z:d Z;e ed      k\  r	ddl?m@Z@mAZA nddlm@Z@mAZA d ZBd ZCd1dZDe ed      k  rddlEmFZF nddlGmFZF d  ZHd! ZId" ZJe5s8ej4                  j                  ZLej4                  j                  ZNd#d$ddddd%d&ZOnd2dePdd'd(ZLddddd)d*ZNd#d$ddddd%d+ZOd, ZQej                  d-fd.ZSg d/ZTy# e
$ r dZ	Y w xY w# e
$ r dZ2Y ;w xY w)3zCompatibility fixes for older version of the dependencies

If you add content to this file, please give the version of the package
at which the fix is no longer needed.
    N)parse)_get_threadpool_controller   P    )wasm32wasm64)sparrayTFc                     | | k7  S N )Xs    @/DATA/.local/lib/python3.12/site-packages/sklearn/utils/fixes.py_object_dtype_isnanr   5   s    6M    c                     t         j                  j                  | |d      }t        t	        d      k\  r|t        j                  |      }|S )NT)axiskeepdimsz1.10.999)scipystatsmode
sp_versionparse_versionnpravel)ar   r   s      r   _moder   :   sC    ;;AD48D]:.. <88D>DKr   z1.12.0z1.15.0c                     d|v r|j                  d      |d<   d|vrd|d<   t        j                  j                  j                  | |fi |S )Nrtoltolatollegacy)popr   sparselinalgcg)Abkwargss      r   _sparse_linalg_cgr*   S   sO    V"JJv.F5M%F6N||""%%a5f55r   z1.11.0c                     | j                  |      }| j                  |      }|<|j                         j                         }|j                         j                         }||fS N)r   )minmaxtoarrayr   r   r   the_minthe_maxs       r   _sparse_min_maxr3   `   s]    %%T%"%%T%"oo'--/Goo'--/Gr   c                     | j                  |      }| j                  |      }|<|j                         j                         }|j                         j                         }||fS r,   )nanminnanmaxr/   r   r0   s       r   _sparse_nan_min_maxr7   j   s]    (((%(((%oo'--/Goo'--/Gr   c                 <   t        j                  t        j                  | j                              } t	        |       | j
                  | j                  | j                  f| j                        } |j                  | j
                  | j                  |         }||fS )N)shape)	r   flatnonzerodiffindptrtypedataindicesr9   reduceat)r   ufuncmajor_indexvalues       r   _minor_reducerD   w   sp    nnRWWQXX%67
 DGQVVQYY1Aqvvqxx'<=E!!r   c           	      6   | j                   |   }|dk(  rt        d      | j                   d|z
     }|dk(  r| j                         n| j                         }|j	                          t        ||      \  }}t        j                  |j                        |   |k  } |||   d      ||<   |dk7  }	t        j                  |	|      }t        j                  |	|      }|dk(  rOt        j                  j                  |t        j                  t        |            |ff| j                  d|f      }
nNt        j                  j                  ||t        j                  t        |            ff| j                  |df      }
|
j!                         j#                         S )Nr   &zero-size array to reduction operation   )dtyper9   )r9   
ValueErrortocsctocsrsum_duplicatesrD   r   r;   r<   compressr   r$   	coo_arrayzeroslenrH   r/   r   )r   r   
min_or_maxNMmatrB   rC   not_fullmaskress              r   _min_or_max_axisrX      se   GGDM6EFFGGAH19aggi!'')*3
;U773::&{3a7$U8_a8hzkk$4D%(19,,((#e*-{;<gg!f ) C ,,((bhhs5z&:;<gg!f ) C
 {{}""$$r   c                    |d| j                   v rt        d      | j                  j                  d      }| j                  dk(  r|S |j                  | j                  j                               }| j                  t        j                  | j                         k7  r	 |||      }|S |dk  r|dz  }|dk(  s|dk(  rt        | ||      S t        d      )Nr   rF      rG   z.invalid axis, use 0 for rows, or 1 for columns)r9   rI   rH   r=   nnzreducer>   r   r   prodrX   )r   r   rQ   zeroms        r   _sparse_min_or_maxr`      s    <AGG| !IJJ77<<?Duuz!!!&&,,.1Auu((tQ'H!8AIDAI419#AtZ88MNNr   c                 n    t        | |t        j                        t        | |t        j                        fS r   )r`   r   minimummaximumr   r   s     r   r3   r3      s,    q$

3q$

3
 	
r   c                 n    t        | |t        j                        t        | |t        j                        fS r   )r`   r   fminfmaxrd   s     r   r7   r7      s,    q$0q$0
 	
r   z1.25.0)ComplexWarningVisibleDeprecationWarningc                 4   t        | j                        j                  }t        |      t        d      k  r"|j                  t        j
                        }|S t        |      t        d      k\  ri nddi}t        |      t        d      k  rN | j                  dd      5   |j                  t        j
                        j                  d	i |}d d d        |S  |j                  t        j
                        j                  d	i |}|S # 1 sw Y   |S xY w)
Nz2.2)rC   3copyFz3.0zfuture.no_silent_downcastingTr   )r   __version__base_versionfillnar   nanoption_contextinfer_objects)pdframe
pd_versioninfer_objects_kwargss       r   	pd_fillnarw      s    r~~.;;JZ =#77266* L  
+}S/AABPU 	 $}U';;"""#A4H@2662@@XCWX I L =ELLrvvL.<<T?STEL	 I Ls    1DDc                    |dk(  r|dv r|dk(  rt        | j                  | j                  ft        | j                  | j
                  d         d      }| j                  j                  |d      | _        | j                  j                  |d      | _        y
t        t        | j
                        	      }| j                  j                  |d      | _        | j                  j                  |d      | _        y
y
y
)a  Preserve indices dtype for SciPy < 1.12 when converting from DIA to CSR/CSC.

    For SciPy < 1.12, DIA arrays indices are upcasted to `np.int64` that is
    inconsistent with DIA matrices. We downcast the indices dtype to `np.int32` to
    be consistent with DIA matrices.

    The converted indices arrays are affected back inplace to the sparse container.

    Parameters
    ----------
    sparse_container : sparse container
        Sparse container to be checked.
    requested_sparse_format : str or bool
        The type of format of `sparse_container`.

    Notes
    -----
    See https://github.com/scipy/scipy/issues/19245 for more details.
    	dia_array)csrcoorz   rG   T)arraysmaxvalcheck_contentsFrl   )r}   N)	 _smallest_admissible_index_dtyper<   r?   r.   r[   r9   astyperowcol)sparse_containeroriginal_container_formatrequested_sparse_formatindex_dtypes       r   _preserve_dia_indices_dtyper      s   , !K/4K P 5 #e+:(//1A1I1IJ+//1A1G1G1JK#K
 (8'?'?'F'F% (G ($ '7&=&=&D&D% 'E '# ;+112K $4#7#7#>#>{QV#>#W #3#7#7#>#>{QV#>#W +5/r   c                 (   t        j                  t        j                  t         j                        j                        }t        j                  t        j                  t         j                        j                        }|T|t        j                  t         j
                        j                  kD  rt        d| d      ||kD  rt         j
                  S t        | t         j                        r| f} | D ]
  }t        |t         j                        st        dt        |       d      t        j                  |j                  t         j                        st        d|j                   d      t        j                  |j                  t         j                        r|st         j
                  c S |j                  dk(  r|j	                         }|j                         }||k  s||kD  st         j
                  c S  t         j                  S )a}  Based on input (integer) arrays `a`, determine a suitable index data
    type that can hold the data in the arrays.

    This function returns `np.int64` if it either required by `maxval` or based on the
    largest precision of the dtype of the arrays passed as argument, or by their
    contents (when `check_contents is True`). If none of the condition requires
    `np.int64` then this function returns `np.int32`.

    Parameters
    ----------
    arrays : ndarray or tuple of ndarrays, default=()
        Input arrays whose types/contents to check.

    maxval : float, default=None
        Maximum value needed.

    check_contents : bool, default=False
        Whether to check the values in the arrays and not just their types.
        By default, check only the types.

    Returns
    -------
    dtype : {np.int32, np.int64}
        Suitable index data type (int32 or int64).
    zmaxval=z+ is to large to be represented as np.int64.z)Arrays should be of type np.ndarray, got z	 instead.zArray dtype z= is not supported for index dtype. We expect integral values.r   )r   int32iinfor-   r.   int64rI   
isinstancendarray	TypeErrorr=   
issubdtyperH   integercan_castsize)r|   r}   r~   int32minint32maxarrminvals          r   r   r     s   6 xx*../Hxx*../HBHHRXX&***&!LM  H88O&"**%#rzz*;DI;iP  }}SYY

3syyk *# #  {{399bhh/! xxxx1}H$(988O/ 2 88Or   z1.12)	laplacianc                 l    	 | j                  |d       y # t        $ r | j                  |       Y y w xY w)Nr>   )filter)
extractallr   )tarfilepaths     r   tarfile_extractallr   W  s9    ! 	4/ !4 !s    33c                      ddl } ddl}t               j                         }t	        d |D              }|syt        d      }|D ]I  }|d   dk7  r|j                  d      }|j                  d	      }|| y
|dk(  s:t        |      |k  sI y
 y)z8Return True if in an unstable configuration for OpenBLASr   Nc              3   ,   K   | ]  }|d    dk(    yw)internal_apiopenblasNr   ).0infos     r   	<genexpr>z6_in_unstable_openblas_configuration.<locals>.<genexpr>j  s     Un-;s   Fz0.3.16r   r   versionarchitectureT
neoversen1)numpyr   r   r   anyr   get)r   r   modules_infoopen_blas_usedopenblas_arm64_stable_versionr   openblas_versionopenblas_architectures           r   #_in_unstable_openblas_configurationr   a  s     -/446LUUUN %2($;!:-88I. $ 8#'<'D!\1./2OO   r   c                 2    t         t        d      k\  ri S | |iS )Nz1.15)r   r   )keyrC   s     r   "_get_additional_lbfgs_options_dictr     s    }V442F3,Fr   g{Gz?r{   )densityformatrH   random_staterngdata_samplerc                n    t         j                  j                  | ||||xs ||      }t        |       |S )N)r   r   rH   r   r   )r   r$   random_array_ensure_sparse_index_int32)r9   r   r   rH   r   r   r   r   s           r   _sparse_random_arrayr     sC     LL%%,% & 
 	#1%r   )krH   r   c                    t         j                  j                  | |||      }t         j                  j                  |      j	                  |      S )N)r   rH   )r   r$   eyery   asformat)r_   nr   rH   r   r'   s         r   _sparse_eye_arrayr     s?    LLQQe4||%%a(11&99r   )offsetsr9   r   rH   c                   t         j                  j                  | |||      }t         j                  j                  |      j	                  |      S )N)r   r9   rH   )r   r$   diagsry   r   )	diagonalsr   r9   r   rH   r'   s         r   _sparse_diags_arrayr     sA     LLy'eT||%%a(11&99r   c                    t        j                  j                  | |||xs ||d}t         j                  j                  |      j	                  |      S )N)r   rH   r   data_rvs)r   r$   randomrN   r   )r9   r   r   rH   r   r   r   r'   s           r   r   r     sN     LL,!
 ||%%a(11&99r   c                 V   | j                   dv rt        |       \  | _        | _        y| j                   dk(  rSt	        | d      rt        |       | _        yt	        | d      rt        |       | _        yt        |       \  | _        | _        y| j                   dk(  rt        |       | _        yy)z*Safely ensure that index arrays are int32.)cscrz   bsrr{   coordsr?   diaN)	r   _safely_cast_index_arraysr?   r<   hasattrr   r   r   r   )r'   s    r   r   r     s    xx((7:	18	
U	1h03AHQ	"1!4AI4Q7LAE15	
U	-a0	 
r    c                   	 t        j                        j                  	| j                  dv r| j                  d   	kD  rt        d|       t        | j                   	kD  r+| j                  	kD  j                         rt        d|       | j                  j                  d      }| j                  j                  d      }||fS | j                  dk(  rt        | dd	      }|'t        | d
d	      }|| j                  | j                  f}t        | j                   	kD  r"t        	fd|D              rt        d|       t        fd|D              S | j                  dk(  r_t        | j                   	kD  r+| j                  	kD  j                         rt        d|       | j                  j                  d      }|S | j                  dk(  r| j                  \  }}| j                  d   |z  	kD  rt        d      t        | j                   	kD  r.| j                  |z  	kD  j                         rt        d|       | j                  j                  d      }| j                  j                  d      }||fS y	)a  Safely cast sparse array indices to `idx_dtype`.

    Check the shape of `A` to determine if it is safe to cast its index
    arrays to dtype `idx_dtype`. If any dimension in shape is larger than
    fits in the dtype, casting is unsafe so raise ``ValueError``.
    If safe, cast the index arrays to `idx_dtype` and return the result
    without changing the input `A`. The caller can assign results to `A`
    attributes if desired or use the recast index arrays directly.

    Unless downcasting is needed, the original index arrays are returned.
    You can test e.g. ``A.indptr is new_indptr`` to see if downcasting occurred.

    See SciPy: scipy.sparse._sputils.py for more info on safely_cast_index_arrays()
    )r   rz   zindptr values too large for zindices values too large for Fr   r{   r   Nr?   c              3   D   K   | ]  }|kD  j                           y wr   )r   )r   co	max_values     r   r   z,_safely_cast_index_arrays.<locals>.<genexpr>  s     ;FbBN'')F    zcoords values too large for c              3   D   K   | ]  }|j                  d         yw)Fr   N)r   )r   r   	idx_dtypes     r   r   z,_safely_cast_index_arrays.<locals>.<genexpr>   s     G"RYYyuY5r   r   zoffsets values too large for r   z!indptr values too large for {msg})r   r   r.   r   r<   rI   r9   r?   r   r   getattrr   r   tupler   	blocksize)
r'   r   msgr?   r<   r   r   RCr   s
    `       @r   r   r     sT    #''Ixx>!88B<)#;C5ABB=9$		I%**, #@!FGG))""95"97	
U	Hd+>Q	40F~%%=9$;F;; #?u!EFFGGGG	
U	=9$		I%**, #@!FGG))""95"9	
U	{{188B<!i'@AA=9$		A	)..0 #@!FGG))""95"97 
r   )
z#3f90daz#ffa90ez#bd1f01z#94a4a2z#832db6z#a96b59z#e76300z#b9ac70z#717581z#92dadd)r   )r   NFr   )U__doc__platformstructr   r   r   scipy.sparse.linalgscipy.statspandasrs   ImportError$sklearn.externals._packaging.versionr   r   sklearn.utils.parallelr   calcsize	_IS_32BITmachine_IS_WASMrm   
np_versionrn   np_base_versionr   sp_base_versionr$   
csr_matrix	csr_arrayCSR_CONTAINERS
csc_matrix	csc_arrayCSC_CONTAINERS
coo_matrixrN   COO_CONTAINERS
lil_matrix	lil_arrayLIL_CONTAINERS
dok_matrix	dok_arrayDOK_CONTAINERS
bsr_matrix	bsr_arrayBSR_CONTAINERS
dia_matrixry   DIA_CONTAINERSscipy.sparser
   SPARRAY_PRESENTr   r   SCIPY_VERSION_BELOW_1_12SCIPY_VERSION_BELOW_1_15r%   r&   r*   r3   r7   rD   rX   r`   numpy.exceptionsrh   ri   rw   r   r   'sklearn.externals._scipy.sparse.csgraphr   scipy.sparse.csgraphr   r   r   	eye_arrayr   diags_arrayr   r   floatr   r   r   PETROFF_COLORSr   r   r   <module>r     s         H =$$*	8!552>>*

 7 785,,-

 7 78 ,,))5<<+A+AB,,))5<<+A+AB,,))5<<+A+AB,,))5<<+A+AB,,))5<<+A+AB,,))5<<+A+AB,,))5<<+A+AB$O

 +]8-DD 
 +]8-DD  mH--++..6 mH--  "%8O$

 x((JJ"+X^BL f%%A!NG  ..,,22
 .:!5 :
 "#$t4: :,1" ,.88 8|I  	B:  Os#   K? L ?L
	L
LL