
    Dj7                     D    d dl mZ d dlZd dlmZ g dZd Zd Zd Zd Z	y)	    )VersionN)NotFittedError)check_is_fittedif_delegate_has_methodsafe_indexingc                     t        |t              r|g}t        |d      st        d      |D ]  }t        | |      s y t	        d      )a3  Ensure the model has been fitted

    Typically called at the beginning of an operation on a model that requires
    having been fit. Raises a ``NotFittedError`` if the model has not been
    fit.

    This is an adaptation of scikit-learn's ``check_is_fitted``, which has been
    changed recently in a way that is no longer compatible with our package.

    Parameters
    ----------
    estimator : estimator instance,
        The estimator that will be checked to see if it is fitted.

    attributes : str or iterable
        The attributes to check for
    __iter__z'attributes must be a string or iterableNzModel has not been fit!)
isinstancestrhasattr	TypeErrorr   )	estimator
attributesattrs      [C:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\pmdarima/compat/sklearn.pyr   r      sU    $ *c" \
:z*ABB 9d# 2
33    c                     t        | d      r| j                  |   S t        | d      r| j                  dk(  r	| |ddf   S | |   S )z:Slice an array or dataframe. This is deprecated in sklearnilocndim   N)r   r   r   )Xindicess     r   r   r   .   sH    q&vvg q&affk!}W:r   c                       fd}|S )a  Checks if the model has a given attribute.

    Meant to be used along with `sklearn.utils.metaestimators.available_if`

    Parameters
    ----------
    attr : str
        The attribute to check the calling object for

    Returns
    -------
    fn : callable
        A function that will either raise an `AttributeError` if the attribute
        does not exist, or True if it does.
    c                     t        |        y)NT)getattr)selfr   s    r   checkz_estimator_has.<locals>.checkJ   s    dr    )r   r   s   ` r   _estimator_hasr   :   s     
 Lr   c                     t        t        j                        t        d      k  rddlm}  ||       S ddlm}  |t        |             S )a  Compat method to replace `sklearn.utils.metaestimators.if_delegate_has`

    Older versions (< 1.0.0) of sklearn support it, but newer versions use
    `available_if` instead.

    References
    ----------
    .. [1] https://git.io/JzKiv
    .. [2] https://git.io/JzKiJ
    z1.0.0r   )r   )available_if)r   sklearn__version__sklearn.utils.metaestimatorsr   r!   r   )r   r   r!   s      r   r   r   R   s=     w""#gg&66G%d++=N4011r   )
packaging.versionr   r"   sklearn.exceptionsr   __all__r   r   r   r   r   r   r   <module>r(      s+    &  -48	02r   