
    t]ee                     r   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	 ddl
mZmZ  e	ej                  Z e	ej                  ZddZe e	d          k    rddlmZ n	dd	lmZ d
 Ze e	d          k     rd ZnddlmZ e e	d          k     rdefdZnddlmZ 	 ddlmZ dS # e$ r d ZY dS w xY w)zCompatibility fixes for older version of python, numpy, scipy, and
scikit-learn.

If you add content to this file, please give the version of the package at
which the fix is no longer needed.
    N)parse_version   )config_context
get_configc                     t           t          d          k    r"t          j                            | |d          S t          j                            | |          S )Nz1.9.0T)axiskeepdims)r   )
sp_versionr   scipystatsmode)ar   s     4lib/python3.11/site-packages/imblearn/utils/fixes.py_moder      sM    ]7++++{t<<<;AD)))    z1.1)_is_arraylike_not_scalar)_is_arraylikec                 J    t          |           ot          j        |            S )z3Return True if array is array-like and not a scalar)r   npisscalar)arrays    r   r   r   #   s"    U##>BK,>,>(>>r   z1.3c                       fd}|S )a  Decorator to run the fit methods of estimators within context managers.

        Parameters
        ----------
        prefer_skip_nested_validation : bool
            If True, the validation of parameters of inner estimators or functions
            called during fit will be skipped.

            This is useful to avoid validating many times the parameters passed by the
            user from the public facing API. It's also useful to avoid validating
            parameters that we pass internally to inner functions that are guaranteed to
            be valid by the test suite.

            It should be set to True for most estimators, except for those that receive
            non-validated objects as parameters, such as meta-estimators that are given
            estimator objects.

        Returns
        -------
        decorated_fit : method
            The decorated fit method.
        c                 J     t          j                    fd            }|S )Nc                     t                      d         }j        dk    ot          |           }|s|s|                                  t	          p|          5   | g|R i |cd d d            S # 1 swxY w Y   d S )Nskip_parameter_validationpartial_fit)r   )r   __name__
_is_fitted_validate_paramsr   )	estimatorargskwargsglobal_skip_validationpartial_fit_and_fitted
fit_methodprefer_skip_nested_validations        r   wrapperz0_fit_context.<locals>.decorator.<locals>.wrapperD   s   )36Q)R& '=8RZ	=R=R ' . 16L 1..000#5O9O   B B
 &:iA$AAA&AAB B B B B B B B B B B B B B B B B Bs   A33A7:A7)	functoolswraps)r%   r'   r&   s   ` r   	decoratorz_fit_context.<locals>.decoratorC   sD    _Z((B B B B B )(B$ Nr    )r&   r*   s   ` r   _fit_contextr,   +   s$    0	 	 	 	 	, r   )r,   c                     |6t          |t          t          f          s|g} | fd|D                       S t           d          r                                 S d t                     D             }t          |          dk    S )a  Determine if an estimator is fitted

        Parameters
        ----------
        estimator : estimator instance
            Estimator instance for which the check is performed.

        attributes : str, list or tuple of str, default=None
            Attribute name(s) given as string or a list/tuple of strings
            Eg.: ``["coef_", "estimator_", ...], "coef_"``

            If `None`, `estimator` is considered fitted if there exist an
            attribute that ends with a underscore and does not start with double
            underscore.

        all_or_any : callable, {all, any}, default=all
            Specify whether all or any of the given attributes must exist.

        Returns
        -------
        fitted : bool
            Whether the estimator is fitted.
        Nc                 0    g | ]}t          |          S r+   )hasattr).0attrr    s     r   
<listcomp>z_is_fitted.<locals>.<listcomp>|   s#    OOODwy$77OOOr   __sklearn_is_fitted__c                 f    g | ].}|                     d           |                    d          ,|/S )___)endswith
startswith)r0   vs     r   r2   z_is_fitted.<locals>.<listcomp>   sK     
 
 
!**S//
BC,,tBTBT

 
 
r   r   )
isinstancelisttupler/   r3   varslen)r    
attributes
all_or_anyfitted_attrss   `   r   r   r   a   s    0 !j4-88 *(\
:OOOOJOOOPPP9566 	522444
 
I
 
 
 <  1$$r   )r   )_is_pandas_dfc                     t          | d          rJt          | d          r:	 t          j        d         }n# t          $ r Y dS w xY wt	          | |j                  S dS )z+Return True if the X is a pandas dataframe.columnsilocpandasF)r/   sysmodulesKeyErrorr:   	DataFrame)Xpds     r   rB   rB      sq    1i   	/WQ%7%7 	/[*   uua...us   5 
AA)r   )__doc__r(   rG   numpyr   r   scipy.statssklearnsklearn.utils.fixesr   _configr   r   __version__r
   sklearn_versionr   sklearn.utils.validationr   r   r,   sklearn.baseallr   rB   ImportErrorr+   r   r   <module>rY      s        



           - - - - - - 0 0 0 0 0 0 0 0]5,--
- 344* * * * mmE****AAAAAAA666666? ? ? ]]5)))). . . .b *))))) ]]5)))))-# #% #% #% #% #%L 43333366666666   	 	 	 	 	 	s   "B* *B65B6