
    0Phx<                     N   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	Z
n# e$ r dZ
Y nw xY w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j        j        gZej        j        gZej        j         gZ!ej        j"        gZ#ej        j$        gZ%ej        j&        gZ'ej        j(        gZ) eej                   ed          k    re*                    ej        j+                   e*                    ej        j,                   e!*                    ej        j-                   e#*                    ej        j.                   e%*                    ej        j/                   e'*                    ej        j0                   e)*                    ej        j1                   	 ddl2m3Z3 dZ4n# e$ r dZ4Y nw xY w	 ddl2m+Z+ dZ5n# e$ r dZ5Y nw xY w	 ddl6m7Z7m8Z8 n# e$ r ddl9m8Z8m7Z7 Y nw xY wd Z:dddZ;e ed          k     re;Z<nddlm<Z< d1dZ=e ed          k    rej        j>        j?        Z@nd Z@e ed          k    rd ZAd ZBnd ZCd ZDd  ZEd! ZAd" ZBe ed#          k    r	dd$lFmGZGmHZH ndd$lmGZGmHZH d% ZId& ZJd2d(ZKe ed)          k     rdd*lLmMZM ndd*lNmMZM d+ ZOd, ZPe
! ee
j                   ed-          k     rd. ZQnd/ ZQd0 ZRdS )3zCompatibility fixes for older version of python, numpy and scipy

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wasm64z1.8)sparrayTF)	csr_array)line_search_wolfe1line_search_wolfe2)r   r   c                     | | k    S N )Xs    S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/utils/fixes.py_object_dtype_isnanr   S   s    6M    linear)methodc                ,    t          j        | |fd|i|S )Ninterpolation)np
percentile)aqr   kwargss       r   _percentiler    Y   s!    =A>>V>v>>>r   z1.22)r   c                    t           t          d          k    rRt          j                            | |d          }t           t          d          k    r|t          j        |          }|S t          j                            | |          S )Nz1.9.0T)axiskeepdimsz1.10.999r"   )
sp_versionparse_versionscipystatsmoder   ravel)r   r"   r)   s      r   _moder+   d   sx    ]7++++{t<<z2222 |x~~;AD)))r   z1.12.0c                     d|v r|                     d          |d<   d|vrd|d<   t          j        j        j        | |fi |S )Nrtoltolatollegacy)popr'   sparselinalgcg)Abr   s      r   _sparse_linalg_cgr7   u   sV    V"JJv..F5M%F6N|"%a55f555r   z1.11.0c                     |                      |          }|                     |          }|L|                                                                }|                                                                }||fS Nr$   )minmaxtoarrayr*   r   r"   the_minthe_maxs       r   _sparse_min_maxr@      so    %%T%""%%T%""oo''--//Goo''--//Gr   c                     |                      |          }|                     |          }|L|                                                                }|                                                                }||fS r9   )nanminnanmaxr<   r*   r=   s       r   _sparse_nan_min_maxrD      so    (((%%(((%%oo''--//Goo''--//Gr   c                    t          j        t          j        | j                            } t	          |           | j        | j        | j        f| j                  } |                    | j        | j        |                   }||fS )N)shape)	r   flatnonzerodiffindptrtypedataindicesrF   reduceat)r   ufuncmajor_indexvalues       r   _minor_reducerQ      so    nRWQX%6%677
 DGGQVQY1AAAqvqx'<==E!!r   c           	      P   | j         |         }|dk    rt          d          | j         d|z
           }|dk    r|                                 n|                                 }|                                 t          ||          \  }}t          j        |j                  |         |k     } |||         d          ||<   |dk    }	t          j	        |	|          }t          j	        |	|          }|dk    rMt          j                            |t          j        t          |                    |ff| j        d|f          }
nLt          j                            ||t          j        t          |                    ff| j        |df          }
|
j                                        S )Nr   &zero-size array to reduction operationr   )dtyperF   )rF   
ValueErrortocsctocsrsum_duplicatesrQ   r   rH   rI   compressr'   r2   
coo_matrixzeroslenrT   r5   r*   )r   r"   
min_or_maxNMmatrO   rP   not_fullmaskress              r   _min_or_max_axisrd      s   GDM66EFFFGAH199aggiii!''))*3
;;U73:&&{3a7$*U8_a88hzk$44D%((199,))#e**--{;<g!f *  CC ,))bhs5zz&:&:;<g!f *  C
 u{{}}r   c                    |d| j         v rt          d          | j                            d          }| j        dk    r|S |                    | j                                                  }| j        t          j	        | j                   k    r |||          }|S |dk     r|dz  }|dk    s|dk    rt          | ||          S t          d          )Nr   rS   r   r   z.invalid axis, use 0 for rows, or 1 for columns)rF   rU   rT   rJ   nnzreducerK   r*   r   prodrd   )r   r"   r]   zeroms        r   _sparse_min_or_maxrk      s    <AG|| !IJJJ7<<??Duzz!!!&,,..11Au((((JtQ''H!88AIDAII4199#AtZ888MNNNr   c                 n    t          | |t          j                  t          | |t          j                  fS r   )rk   r   minimummaximumr   r"   s     r   r@   r@      s.    q$
33q$
33
 	
r   c                 n    t          | |t          j                  t          | |t          j                  fS r   )rk   r   fminfmaxro   s     r   rD   rD      s.    q$00q$00
 	
r   z1.25.0)ComplexWarningVisibleDeprecationWarningc                    t          | j                  j        }t          |          t          d          k     r!|                    t          j                  }nzt          |          t          d          k    ri nddi} | j        dd          5   |                    t          j                  j        di |}d d d            n# 1 swxY w Y   |S )	Nz2.2)rP   3copyFzfuture.no_silent_downcastingTr   )r&   __version__base_versionfillnar   nanoption_contextinfer_objects)pdframe
pd_versioninfer_objects_kwargss       r   	pd_fillnar      s   r~..;JZ  =#7#77726**  
++}S/A/AAABBPU 	 R=tDD 	U 	U<ELLrvL..<TT?STTE	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	U 	ULs   ,C

CCc                    |dk    r|dv r|dk    rt          | j        | j        ft          | j        | j        d                   d          }| j                            |d          | _        | j                            |d          | _        d
S t          t          | j                  	          }| j                            |d          | _        | j                            |d          | _        d
S d
S d
S )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coor   r   T)arraysmaxvalcheck_contentsF)rw   )r   N)	 _smallest_admissible_index_dtyperI   rL   r;   rf   rF   astyperowcol)sparse_containeroriginal_container_formatrequested_sparse_formatindex_dtypes       r   _preserve_dia_indices_dtyper      sF   , !K//4K P 5 5 #e++:(/1A1IJ+/1A1G1JKK#  K
 (8'?'F'F% (G ( ($ '7&=&D&D% 'E ' '### ;+122  K $4#7#>#>{QV#>#W#W #3#7#>#>{QV#>#W#W   + 0/ 5 5r   r   c                    t          j        t          j        t           j                  j                  }t          j        t          j        t           j                  j                  }|L|t          j        t           j                  j        k    rt          d| d          ||k    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                  s^|st           j        c S |j        dk    r|                                }|                                }||k     s||k    r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 the 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).
    Nz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;   int64rU   
isinstancendarray	TypeErrorrJ   
issubdtyperT   integercan_castsize)r   r   r   int32minint32maxarrminvals          r   r   r   $  s   6 x**.//Hx**.//HBHRX&&***M&MMM   H8O&"*%%  $ $#rz** 	PDIIPPP   }SY
33 	#sy # # #   {39bh// 	$!   xx1}}H$$(9(98OOO8Or   z1.12)	laplacianc                     	 |                      |d           d S # t          $ r |                      |           Y d S w xY w)NrK   )filter)
extractallr   )tarfilepaths     r   tarfile_extractallr   u  s^    !4///// ! ! !4      !s    >>c                  l   ddl } ddl}t                                                      }t	          d |D                       }|sdS t          d          }|D ]\}|d         dk    r|                    d          }|                    d	          }|| d
S |dk    rt          |          |k     r d
S ]dS )z8Return True if in an unstable configuration for OpenBLASr   Nc              3   .   K   | ]}|d          dk    V  dS )internal_apiopenblasNr   ).0infos     r   	<genexpr>z6_in_unstable_openblas_configuration.<locals>.<genexpr>  s,      UUn-;UUUUUUr   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   |  s     LLLLLL-//4466LUUUUUUUN u %2($;$;!  :--88I.. $ 8 8#'<'D44!\11.//2OOO 445r   z1.4c                    t           j                            d          }|t          | |j                  st          j        | ||          S t          j        |                                 ||          S )Npolarsindexrw   )sysmodulesr   r   	DataFramer~   to_numpy)r   r   rw   pls       r   2_create_pandas_dataframe_from_non_pandas_containerr     sb    [__X&&:Z2<88:<T:::: |AJJLLDAAAAr   c                0    t          j        | ||          S )Nr   )r~   r   )r   r   rw   s      r   r   r     s    |AU6666r   c                  .    t           j        dk     ri S ddiS )N)   
   slotsT)r   version_infor   r   r   _dataclass_argsr     s    
'!!	T?r   )r   )r   NF)S__doc__platformstructr   r   r   r'   scipy.sparse.linalgscipy.statspandasr~   ImportErrorexternals._packaging.versionr   r&   parallelr   calcsize	_IS_32BITmachine_IS_WASMrx   
np_versionry   np_base_versionr%   sp_base_versionr2   
csr_matrixCSR_CONTAINERS
csc_matrixCSC_CONTAINERSrZ   COO_CONTAINERS
lil_matrixLIL_CONTAINERS
dok_matrixDOK_CONTAINERS
bsr_matrixBSR_CONTAINERS
dia_matrixDIA_CONTAINERSappendr   	csc_array	coo_array	lil_array	dok_array	bsr_arrayr   scipy.sparser   SPARRAY_PRESENTSPARSE_ARRAY_PRESENTscipy.optimize._linesearchr   r   scipy.optimize.linesearchr   r    r   r+   r3   r4   r7   r@   rD   rQ   rd   rk   numpy.exceptionsrs   rt   r   r   r   externals._scipy.sparse.csgraphr   scipy.sparse.csgraphr   r   r   r   r   r   r   <module>r      s      



                	BBB B A A A A A 0 0 0 0 0 0$$$*	8!55]2>**
-
 788]5,--
-
 788 ,)*,)*,)*,)*,)*,)*,)*="##}}U';';;;
 %,0111%,0111%,0111%,0111%,0111%,0111%,0111$$$$$$OO   OOO
!&&&&&& ! ! ! !QQQQQQQQQQ Q Q QPPPPPPPPPPQ   !) ? ? ? ? ? f%%%%JJ      	* 	* 	* 	* mmH----+.6 6 6 mmH----            " " "  8O O O$
 
 

 
 
 x((((JJJJJJJJJ????????
 
 
+X +X +X^B B B BL f%%%%;;;;;;;......! ! !  D >mmBN33mmE6J6JJJB B B B7 7 7
    sB   % //8H H
HH H"!H"&H/ /H?>H?