o
    ik;                     @   s  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mZ zddl	Z
W n ey1   dZ
Y nw 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ejjgZejjejj gZ!ejj"ejj#gZ$ejj%ejj&gZ'ejj(ejj)gZ*ejj+ejj,gZ-ejj.ejj/gZ0z
ddl1m2Z2 dZ3W n ey   dZ3Y nw dd Z4d7ddZ5eedkrejj6j7Z8ndd Z8dd Z9eedkrdd Z:dd Z;ndd Z<dd  Z=d!d" Z>d#d Z:d$d Z;eed%krdd&l?m@Z@mAZA ndd&lm@Z@mAZA d'd( ZBd)d* ZCd8d,d-ZDeed.k r!dd/lEmFZF ndd/lGmFZF d0d1 ZHd2d3 ZId4d5 ZJdZKzddlLZLeeLjZMeMed6k rKdZKW dS W dS  eNyX   Y dS w )9zCompatibility 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)optimize   )parse   )_get_threadpool_controller   P    )Zwasm32Zwasm64)sparrayTFc                 C   s   | | kS N )Xr   r   b/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sklearn/utils/fixes.py_object_dtype_isnan6   s   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 )N1.9.0T)axisZkeepdimsz1.10.999r   )
sp_versionparse_versionscipystatsmodenpravel)ar   r   r   r   r   _mode;   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bkwargsr   r   r   _sparse_linalg_cgL   s
   r$   c                 C   s6   d}t t|k rtj| ddS tjj|dd\}}|S )a  Estimate the optimal Yeo-Johnson transformation parameter (lambda).

    This function provides a compatibility workaround for versions of SciPy
    older than 1.9.0, where `scipy.stats.yeojohnson` did not return
    the estimated lambda directly.

    Parameters
    ----------
    _neg_log_likelihood : callable
        A function that computes the negative log-likelihood of the Yeo-Johnson
        transformation for a given lambda. Used only for SciPy versions < 1.9.0.

    x : array-like
        Input data to estimate the Yeo-Johnson transformation parameter.

    Returns
    -------
    lmbda : float
        The estimated lambda parameter for the Yeo-Johnson transformation.
    r   )r   )ZbrackN)lmbda)r   r   r   Zbrentr   r   Z
yeojohnson)Z_neg_log_likelihoodxZmin_scipy_version_r&   r   r   r   _yeojohnson_lambdaU   s
   r)   z1.11.0c                 C   @   | j |d}| j|d}|d ur|  }|  }||fS Nr   )minmaxtoarrayr   r   r   Zthe_minZthe_maxr   r   r   _sparse_min_maxy      r0   c                 C   r*   r+   )ZnanminZnanmaxr.   r   r/   r   r   r   _sparse_nan_min_max   r1   r2   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indicesr3   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r|  n|  }|  t||\}}t|j| |k }||| d||< |dk}	t	|	|}t	|	|}|dkrht
jj|tt||ff| jd|fd}
nt
jj||tt|ff| j|dfd}
|
  S )Nr   &zero-size array to reduction operationr   )dtyper3   )r3   
ValueErrorZtocscZtocsrZsum_duplicatesr;   r   r4   r5   compressr   r   
coo_matrixZzeroslenr=   r.   r   )r   r   
min_or_maxNMmatr9   r:   not_fullmaskresr   r   r   _min_or_max_axis   s0   
rI   c                 C   s   |d u r2d| j v rtd| jd}| jdkr|S || j }| jt	| j kr0|||}|S |dk r:|d7 }|dksB|dkrHt
| ||S td)Nr   r<   r   r   z.invalid axis, use 0 for rows, or 1 for columns)r3   r>   r=   r6   nnzreducer7   r   r   prodrI   )r   r   rB   zeromr   r   r   _sparse_min_or_max   s   


rO   c                 C      t | |tjt | |tjfS r   )rO   r   minimummaximumr   r   r   r   r   r0         c                 C   rP   r   )rO   r   ZfminZfmaxrS   r   r   r   r2      rT   z1.25.0)ComplexWarningVisibleDeprecationWarningc                 C   s   t | jj}t |t dk r|jtjd}|S t |t dkr!i nddi}| dd |jtjdjdi |}W d    |S 1 sDw   Y  |S )	Nz2.2)r:   3copyFzfuture.no_silent_downcastingTr   )r   __version__base_versionZfillnar   nanZoption_contextZinfer_objects)pdframeZ
pd_versionZinfer_objects_kwargsr   r   r   	pd_fillna   s   
r^   c                 C   s   |dkrN|dv rP|dkr2t | j| jft| j| jd dd}| jj|dd| _| jj|dd| _d
S t t| jd	}| jj|dd| _| jj|d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)csrZcoor`   r   T)arraysmaxvalcheck_contentsF)rX   )rb   N)	 _smallest_admissible_index_dtyper5   r8   r-   rJ   r3   Zastyperowcol)Zsparse_containerZoriginal_container_formatZrequested_sparse_formatZindex_dtyper   r   r   _preserve_dia_indices_dtype   s&   
rg   r   c                 C   s  t t t jj}t t t jj}|dur0|t t jjkr)td| d||kr0t jS t| t jr9| f} | D ]M}t|t jsMt	dt
| dt |jt js^td|j dt |jt js|smt j  S |jdkrsq;| }| }||k s||krt j  S q;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).
    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	TypeErrorr6   Z
issubdtyper=   integerZcan_castsize)ra   rb   rc   Zint32minZint32maxZarrminvalr   r   r   rd     s>   



rd   z1.12)	laplacianc                 C   s4   z
| j |dd W d S  ty   |  | Y d S w )Nr7   )filter)
extractallri   )tarfilepathr   r   r   tarfile_extractallm  s
   rr   c                  C   s   ddl } ddl}t  }tdd |D }|sdS td}|D ]+}|d dkr)q |d	}|d
}|du s;|du r> dS |dkrKt||k rK 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>  s    z6_in_unstable_openblas_configuration.<locals>.<genexpr>Fz0.3.16rs   rt   versionarchitectureTZ
neoversen1)numpyr   r   rv   anyr   get)rz   r   Zmodules_infoZopen_blas_usedZopenblas_arm64_stable_versionrv   Zopenblas_versionZopenblas_architecturer   r   r   #_in_unstable_openblas_configurationw  s&   


r}   c                 C   s   t tdkri S | |iS )Nz1.15)r   r   )keyr:   r   r   r   "_get_additional_lbfgs_options_dict  s   r   z17.0.0)r   )r   NF)O__doc__platformstructrz   r   r   Zscipy.sparse.linalgZscipy.statsr   Zpandasr\   ImportErrorZexternals._packaging.versionr   r   Zparallelr   calcsizeZ	_IS_32BITmachineZ_IS_WASMrY   Z
np_versionrZ   Znp_base_versionr   Zsp_base_versionr   Z
csr_matrixZ	csr_arrayZCSR_CONTAINERSZ
csc_matrixZ	csc_arrayZCSC_CONTAINERSr@   Z	coo_arrayZCOO_CONTAINERSZ
lil_matrixZ	lil_arrayZLIL_CONTAINERSZ
dok_matrixZ	dok_arrayZDOK_CONTAINERSZ
bsr_matrixZ	bsr_arrayZBSR_CONTAINERSZ
dia_matrixr_   ZDIA_CONTAINERSZscipy.sparser
   ZSPARRAY_PRESENTr   r   r   r    r$   r)   r0   r2   r;   rI   rO   Znumpy.exceptionsrU   rV   r^   rg   rd   Zexternals._scipy.sparse.csgraphrm   Zscipy.sparse.csgraphrr   r}   r   ZPYARROW_VERSION_BELOW_17ZpyarrowZpyarrow_versionModuleNotFoundErrorr   r   r   r   <module>   s    	




	"

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