a
    hx<                     @   sx  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zddl	Z
W n ey^   dZ
Y n0 ddlmZ ddlmZ ded d	kZe 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rze*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 zddl2m3Z3 dZ4W n ey   dZ4Y n0 zddl2m+Z+ dZ5W n ey   dZ5Y n0 zddl6m7Z7m8Z8 W n$ ey   ddl9m8Z8m7Z7 Y n0 dd Z:ddddZ;eedk r:e;Z<nddlm<Z< dAddZ=eedkrjejj>j?Z@ndd Z@eedkrd d! ZAd"d# ZBn(d$d% ZCd&d' ZDd(d) ZEd*d! ZAd+d# ZBeed,krdd-lFmGZGmHZH ndd-lmGZGmHZH d.d/ ZId0d1 ZJdBd3d4ZKeed5k r dd6lLmMZM ndd6lNmMZM d7d8 ZOd9d: ZPe
durdee
jed;k rdd<d= ZQnd>d= ZQd?d@ ZRdS )CzCompatibility 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    )Zwasm32Zwasm64z1.8)sparrayTF)	csr_array)line_search_wolfe1line_search_wolfe2)r   r   c                 C   s   | | kS N )Xr   r   O/var/www/html/assistant/venv/lib/python3.9/site-packages/sklearn/utils/fixes.py_object_dtype_isnanS   s    r   Zlinear)methodc                K   s   t j| |fd|i|S )Ninterpolation)np
percentile)aqr   kwargsr   r   r   _percentileY   s    r   z1.22)r   c                 C   sP   t tdkr@tjj| |dd}t tdkr<|d u r<t|}|S tjj| |dS )Nz1.9.0T)axisZkeepdimsz1.10.999r   )
sp_versionparse_versionscipystatsmoder   ravel)r   r   r    r   r   r   _moded   s    
r"   z1.12.0c                 K   s>   d|v r| d|d< d|vr&d|d< tjjj| |fi |S )NZrtolZtolZatollegacy)popr   sparselinalgcg)Abr   r   r   r   _sparse_linalg_cgu   s
    r*   z1.11.0c                 C   s@   | j |d}| j|d}|d ur8|  }|  }||fS Nr   )minmaxtoarrayr!   r   r   Zthe_minZthe_maxr   r   r   _sparse_min_max   s    r0   c                 C   s@   | j |d}| j|d}|d ur8|  }|  }||fS r+   )ZnanminZnanmaxr.   r!   r/   r   r   r   _sparse_nan_min_max   s    r1   c                 C   sL   t t | j}t| | j| j| jf| jd} || j| j| }||fS )N)shape)	r   Zflatnonzerodiffindptrtypedataindicesr2   Zreduceat)r   Zufuncmajor_indexvaluer   r   r   _minor_reduce   s    r:   c                 C   s  | j | }|dkrtd| j d|  }|dkr8|  n|  }|  t||\}}t|j| |k }||| d||< |dk}	t	|	|}t	|	|}|dkrt
jj|tt||ff| jd|fd}
n*t
jj||tt|ff| j|dfd}
|
j S )Nr   &zero-size array to reduction operationr   )dtyper2   )r2   
ValueErrorZtocscZtocsrZsum_duplicatesr:   r   r3   r4   compressr   r%   
coo_matrixZzeroslenr<   r(   r!   )r   r   
min_or_maxNMZmatr8   r9   not_fullmaskresr   r   r   _min_or_max_axis   s0    
rG   c                 C   s   |d u rdd| j v rtd| jd}| jdkr4|S || j }| jt	| j kr`|||}|S |dk rt|d7 }|dks|dkrt
| ||S tdd S )Nr   r;   r   r   z.invalid axis, use 0 for rows, or 1 for columns)r2   r=   r<   r5   nnzreducer6   r!   r   prodrG   )r   r   rA   zeromr   r   r   _sparse_min_or_max   s    


rM   c                 C   s   t | |tjt | |tjfS r   )rM   r   minimummaximumr   r   r   r   r   r0      s    c                 C   s   t | |tjt | |tjfS r   )rM   r   ZfminZfmaxrP   r   r   r   r1      s    z1.25.0)ComplexWarningVisibleDeprecationWarningc                 C   s   t | jj}t |t dk r,|jtjd}nbt |t dkr@i nddi}| dd* |jtjdjf i |}W d    n1 s0    Y  |S )Nz2.2)r9   3copyFzfuture.no_silent_downcastingT)r   __version__base_versionZfillnar   nanZoption_contextZinfer_objects)pdframeZ
pd_versionZinfer_objects_kwargsr   r   r   	pd_fillna   s    8rZ   c                 C   s   |dkr|dv r|dkrbt | j| jft| j| jd dd}| jj|dd| _| jj|dd| _n4t t| jd	}| jj|dd| _| jj|dd| _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)csrZcoor\   r   T)arraysmaxvalcheck_contentsF)rT   )r^   N)	 _smallest_admissible_index_dtyper4   r7   r-   rH   r2   Zastyperowcol)Zsparse_containerZoriginal_container_formatZrequested_sparse_formatZindex_dtyper   r   r   _preserve_dia_indices_dtype   s$    

rc   r   c                 C   s  t t t jj}t t t jj}|dur`|t t jjkrRtd| d||kr`t jS t| t jrr| f} | D ]}t|t jst	dt
| dt |jt jstd|j dt |jt jsv|st j  S |jdkrqvqv| }| }||k s
||krvt j  S qvt 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   Zint32Ziinfor,   r-   Zint64r=   
isinstanceZndarray	TypeErrorr5   Z
issubdtyper<   integerZcan_castsize)r]   r^   r_   Zint32minZint32maxZarrminvalr   r   r   r`   $  s<    


r`   z1.12)	laplacianc                 C   s4   z| j |dd W n ty.   |  | Y n0 d S )Nr6   )filter)
extractallre   )tarfilepathr   r   r   tarfile_extractallu  s    rn   c                  C   s   ddl } ddl}t  }tdd |D }|s4dS td}|D ]V}|d dkrRq@|d	}|d
}|du sv|du r| dS |dkr@t||k r@ dS q@dS )z8Return True if in an unstable configuration for OpenBLASr   Nc                 s   s   | ]}|d  dkV  qdS )internal_apiopenblasNr   ).0infor   r   r   	<genexpr>      z6_in_unstable_openblas_configuration.<locals>.<genexpr>Fz0.3.16ro   rp   versionarchitectureTZ
neoversen1)numpyr   r   rr   anyr   get)rw   r   Zmodules_infoZopen_blas_usedZopenblas_arm64_stable_versionrr   Zopenblas_versionZopenblas_architecturer   r   r   #_in_unstable_openblas_configuration|  s(    



rz   z1.4c                C   sD   t jd}|d u s t| |js0tj| ||dS tj|  ||dS )NZpolarsindexrT   )sysmodulesry   rd   	DataFramerX   Zto_numpy)r   r|   rT   plr   r   r   2_create_pandas_dataframe_from_non_pandas_container  s    r   c                C   s   t j| ||dS )Nr{   )rX   r   )r   r|   rT   r   r   r   r     s    c                   C   s   t jdk ri S ddiS )N)   
   slotsT)r}   version_infor   r   r   r   _dataclass_args  s    
r   )r   )r   NF)S__doc__platformstructr}   rw   r   r   Zscipy.sparse.linalgZscipy.statsZpandasrX   ImportErrorZexternals._packaging.versionr   r   parallelr   calcsizeZ	_IS_32BITmachineZ_IS_WASMrU   Z
np_versionrV   Znp_base_versionr   Zsp_base_versionr%   Z
csr_matrixZCSR_CONTAINERSZ
csc_matrixZCSC_CONTAINERSr?   ZCOO_CONTAINERSZ
lil_matrixZLIL_CONTAINERSZ
dok_matrixZDOK_CONTAINERSZ
bsr_matrixZBSR_CONTAINERSZ
dia_matrixZDIA_CONTAINERSappendr
   Z	csc_arrayZ	coo_arrayZ	lil_arrayZ	dok_arrayZ	bsr_arrayr[   Zscipy.sparser	   ZSPARRAY_PRESENTZSPARSE_ARRAY_PRESENTZscipy.optimize._linesearchr   r   Zscipy.optimize.linesearchr   r   r   r"   r&   r'   r*   r0   r1   r:   rG   rM   Znumpy.exceptionsrQ   rR   rZ   rc   r`   Zexternals._scipy.sparse.csgraphri   Zscipy.sparse.csgraphrn   rz   r   r   r   r   r   r   <module>   s   	

















	/
F"
