
    i/                     p    d dl Zd dlmZmZ d dlmc mZ ddgZ	i Z
 G d de      ZddZd Zd	 Zd
 Zd Zy)    N)NAAction	dmatriceshandle_formula_dataformula_handlerc                       e Zd Zd Zy)r   c                     t        j                  |d   j                  d   t              }|D ]  }||z  }	 | }|| _        |D cg c]  }|j
                  dk(  r||   n||df    c}S c c}w )Nr   )dtype   .)npzerosshapeboolmissing_maskndim)selfvaluesis_NAsorigins
total_maskis_NA	good_maskvs           f/home/ubuntu/crypto_trading_bot/.venv/lib/python3.12/site-packages/statsmodels/formula/formulatools.py_handle_NA_dropzNAAction._handle_NA_drop   sw    XXfQiooa0=
 	 E%J	 K	&LRSq!)9c>1BBSSSs   "A+N)__name__
__module____qualname__r        r   r   r      s    Tr   r   c                    t        |t        t        j                                     rt        t	        |         S t        |      }|<t        j                  | |      rt        || |f|d|      }nJt        || |f|d|      }n7t        j                  | d      rt        || |d|      }nt        || |d|      }t        |dd      }t        j                  |      sd}t        |      dkD  r|d   j                  }nd}|||fS )a;  
    Returns endog, exog, and the model specification from arrays and formula.

    Parameters
    ----------
    Y : array_like
        Either endog (the LHS) of a model specification or all of the data.
        Y must define __getitem__ for now.
    X : array_like
        Either exog or None. If all the data for the formula is provided in
        Y then you must explicitly set X to None.
    formula : str or patsy.model_desc
        You can pass a handler by import formula_handler and adding a
        key-value pair where the key is the formula object class and
        the value is a function that returns endog, exog, formula object.

    Returns
    -------
    endog : array_like
        Should preserve the input type of Y,X.
    exog : array_like
        Should preserve the input type of Y,X. Could be None.
    )on_NAN	dataframe)return_type	NA_actionr   r
   )
isinstancetupler   keystyper   	data_util_is_using_pandasr   getattrr   anylendesign_info)	YXformuladepthmissing	na_actionresultr   r.   s	            r   r   r      s	   2 '5!5!5!789tG}--w'I}%%a+!QK9F !QK9F %%a.E{iF E{iF
 9nd;L66,
6{QQi++<,,r   c                 <    ddl m} || v r| j                  |       | S )z,
    Remove intercept from Patsy terms.
    r   	INTERCEPT)
patsy.descr8   remove)termsr8   s     r   _remove_intercept_patsyr<   X   s      %EYLr   c                 *    ddl m} || j                  v S )Nr   r7   )r9   r8   r;   )r.   r8   s     r   _has_interceptr>   c   s    $))))r   c                 j    ddl m} ddlm}  || j                  D cg c]  }||k(  	 c}      S c c}w )zR
    Returns boolean array index indicating which column holds the intercept.
    r   )arrayr7   )numpyr@   r9   r8   r;   )r.   r@   r8   is       r   _intercept_idxrC   i   s-     $+*;*;<Q)q.<==<s   0c                 P    ddl m} | j                  j                  } |||      }|S ) r   )linear_constraint)patsy.constraintrF   model
exog_names)model_resultstest_formularF   rI   LCs        r   make_hypotheses_matricesrM   s   s'    2$$//J	<	4BIr   )r   drop)rA   r   patsyr   r   statsmodels.tools.datatoolsdatar)   __all__r   r   r<   r>   rC   rM   r   r   r   <module>rT      sM     % * *
 !"3
4 	Tx 	T:-z*>r   