
    "gi                          d Z ddlZddZddZy)z4
SARIMAX tools.

Author: Chad Fulton
License: BSD-3
    Nc           	         t        j                  |       } |dnd|z  }t        j                  | | j                  t              k(        st        d|d| d      | j                  t              } t        j                  | dk        rt        d|z        | j                  d	k(  r| j                  d
   d
k(  r
| dddf   } n!| j                  d
kD  rt        d|d| d      | j                  dk(  r| j                         } nt        |       dk(  rd} nd| v }t        j                  | d
k(        d
kD  }t        j                  | d
kD        }|s|r/|rt        d|z        t        j                  | d
k(        d   d
z   } nt        j                  |       } t        |       dk(  rd} nNt        j                  | t        j                  d
t        |       d
z         k(        r| d   } n| j                         } t!        | t"              xr+ t        j                  t        j$                  |       dk(        }|rt        d|z        | S )a+  
    Standardize lag order input.

    Parameters
    ----------
    order : int or array_like
        Maximum lag order (if integer) or iterable of specific lag orders.
    title : str, optional
        Description of the order (e.g. "autoregressive") to use in error
        messages.

    Returns
    -------
    order : int or list of int
        Maximum lag order if consecutive lag orders were specified, otherwise
        a list of integer lag orders.

    Notes
    -----
    It is ambiguous if order=[1] is meant to be a boolean list or
    a list of lag orders to include, but this is irrelevant because either
    interpretation gives the same result.

    Order=[0] would be ambiguous, except that 0 is not a valid lag
    order to include, so there is no harm in interpreting as a boolean
    list, in which case it is the same as order=0, which seems like
    reasonable behavior.

    Examples
    --------
    >>> standardize_lag_order(3)
    3
    >>> standardize_lag_order(np.arange(1, 4))
    3
    >>> standardize_lag_order([1, 3])
    [1, 3]
    Norderz%s orderzInvalid z. Non-integer order (z) given.r   z#Terms in the %s cannot be negative.      zX. Must be an integer or 1-dimensional array-like object (e.g. list, ndarray, etc.). Got .zInvalid %s. Appears to be a boolean list (since it contains a 0 element and/or multiple elements) but also contains elements greater than 1 like a list of lag orders.z+Invalid %s. Cannot have duplicate elements.)nparrayallastypeint
ValueErroranyndimshapeitemlensumwheresortarangetolist
isinstancelistdiff)r   title	has_zeroshas_multiple_ones
has_gt_onehas_duplicates         X/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/tsa/arima/tools.pystandardize_lag_orderr"   
   s   L HHUOE}G*u*<E 66%5<<,,-!5* + 	+LLE 
vveai>FGG zzQ5;;q>Q.ad	a7<eE F 	F zzQ

	Uq %Z	FF5A:.2VVEAI&
)  "0 38	"8 9 9
 XXeqj)!,q0E GGENE u:?EVVERYYq#e*q.99:"IE LLNE ud+Krwwu~7J0KMFNOOL    c                    |dnd|z  }	 t        j                  | t              } | j                         D cg c]  }t	        |t
               }}t        |      rt
        nt        }t        j                  | |      } |s^t        j                  t        j                  |             s(t        j                  t        j                  |             rt        d|z        t        j                  t        j                  |             } | j                  |fk7  r%|dk(  rdnd}t        d|||| j                  fz        | S c c}w # t        $ r t        d|z        w xY w)	a  
    Validate parameter vector for basic correctness.

    Parameters
    ----------
    params : array_like
        Array of parameters to validate.
    length : int
        Expected length of the parameter vector.
    allow_infnan : bool, optional
            Whether or not to allow `params` to contain -np.inf, np.inf, and
            np.nan. Default is False.
    title : str, optional
        Description of the parameters (e.g. "autoregressive") to use in error
        messages.

    Returns
    -------
    params : ndarray
        Array of validated parameters.

    Notes
    -----
    Basic check that the parameters are numeric and that they are the right
    shape. Optionally checks for NaN / infinite values.
     z for %s)dtypez,Parameters vector%s includes invalid values.z/Parameters vector%s includes NaN or Inf values.r   szOSpecification%s implies %d parameter%s, but values with shape %s were provided.)r	   r
   objectravelr   complexr   float	TypeErrorr   isnanisinf
atleast_1dsqueezer   )paramslengthallow_infnanr   p
is_complexr&   plurals           r!   validate_basicr7   o   sC   6 -BY%6E"&/6<llnEjG,E
Ez?&. RVVBHHV$45VVBHHV$45J ! " 	" ]]2::f-.F ||y { @!666<<@A B 	B M- F  "G ! " 	""s   -E D>0E >E E)N)FN)__doc__numpyr	   r"   r7    r#   r!   <module>r;      s    bJ6r#   