
    Dj
                         d dl Zd dlZd dlZddlmZ  G d deej                        Z G d deej                        Z	y)	    N   )BaseTransformerc                   $     e Zd ZdZd fd	Z xZS )BaseExogTransformerz-A base class for exogenous array transformersc                 X    t         t        |   ||      \  }}||st        d      ||fS )zCheck the endog and exog arraysz(X must be non-None for exog transformers)superr   
_check_y_X
ValueError)selfyXnull_allowed	__class__s       dC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\pmdarima/preprocessing/exog/base.pyr	   zBaseExogTransformer._check_y_X   s7    ($:1a@19\GHH!t    )F)__name__
__module____qualname____doc__r	   __classcell__)r   s   @r   r   r   
   s    7 r   r   )	metaclassc                   P    e Zd ZdZddZej                  d        Zd Zd Z	d	dZ
y)
BaseExogFeaturizerzTransformers that create new exog features from the endog or exog array

    Parameters
    ----------
    prefix : str or None, optional (default=None)
        The feature prefix
    Nc                     || _         y N)prefix)r   r   s     r   __init__zBaseExogFeaturizer.__init__   s	    r   c                      y)z6Get the feature prefix for when exog is a pd.DataFrameN )r   s    r   _get_prefixzBaseExogFeaturizer._get_prefix        r   c                     | j                         }t        |j                  d         D cg c]	  }d||fz   c}S c c}w )N   z%s_%i)r    rangeshape)r   r   pfxis       r   _get_feature_namesz%BaseExogFeaturizer._get_feature_names$   s:     ,1!''!*,=>q3(">>>s   <c                    |t        |t        j                        rt        |t        j                        st        j                  j                  |      }| j	                  |      |_        |Gt        j                  |j                  d         x|_	        |_	        t        j                  ||gd      S |S t        j                  ||g      S )z!H-stack dataframes or np.ndarraysr   r#   )axis)
isinstancepd	DataFramefrom_recordsr(   columnsnparanger%   indexconcathstack)r   r   featuress      r   _safe_hstackzBaseExogFeaturizer._safe_hstack(   s    9
1bll3h5<<44X>  $66x@H} ,.99QWWQZ+@@(.yy!XQ77Oyy!X''r   c                      y)ai  Transform the new array

        Apply the transformation to the array after learning the training set's
        characteristics in the ``fit`` method. The transform method for
        featurizers behaves slightly differently in that the ``n_periods` may
        be required to extrapolate for periods in the future.

        Parameters
        ----------
        y : array-like or None, shape=(n_samples,)
            The endogenous (time-series) array.

        X : array-like or None, shape=(n_samples, n_features)
            An array of additional covariates.

        n_periods : int, optional (default=0)
            The number of periods in the future to forecast. If ``n_periods``
            is 0, will compute the features for the training set.
            ``n_periods`` corresponds to the number of samples that will be
            returned.

        **kwargs : keyword args
            Keyword arguments required by the transform function.

        Returns
        -------
        y : array-like or None
            The transformed y array

        X : array-like or None
            The transformed X array
        Nr   )r   r   r   	n_periodskwargss        r   	transformzBaseExogFeaturizer.transform=   r!   r   r   )Nr   )r   r   r   r   r   abcabstractmethodr    r(   r6   r:   r   r   r   r   r      s7     	E E?(* r   r   )
pandasr,   numpyr0   r;   baser   ABCMetar   r   r   r   r   <module>rA      s:      
 "/S[[ H, Hr   