
    "g                     h    d dl mc mZ d dlmZmZ d dlZi Z	 G d de      Zd
dZ
d Zd Zd Zd	 Zy)    N)	dmatricesNAActionc                       e Zd Zd Zy)r   c                     t        j                  |d   j                  d   t              }|D ]  }||z  }	 | }|| _        |D cg c]	  }||df    c}S c c}w )Nr   )dtype.)npzerosshapeboolmissing_mask)selfvaluesis_NAsorigins
total_maskis_NA	good_maskvs           ]/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/formula/formulatools.py_handle_NA_dropzNAAction._handle_NA_drop   sd    XXfQiooa0=
 	 E%J	 K	&+12a)S.!222s   AN)__name__
__module____qualname__r        r   r   r      s    3r   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      )
isinstancetupleformula_handlerkeystyper   	data_util_is_using_pandasr   getattrr   anylendesign_info)	YXformuladepthmissing	na_actionresultr   r,   s	            r   handle_formula_datar4      s   2 '5!5!5!789tG}--w'I}%%a+wA+6)MF wA+6)MF %%a.w5k)24F w5k)24F 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.descr7   remove)termsr7   s     r   _remove_intercept_patsyr;   Q   s      %EYLr   c                 *    ddl m} || j                  v S )Nr   r6   )r8   r7   r:   )r,   r7   s     r   _has_interceptr=   [   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   r6   )array)r8   r7   numpyr?   r:   )r,   r7   r?   is       r   _intercept_idxrB   `   s-     %+*;*;<Q)q.<==<s   0c                 P    ddl m} | j                  j                  } |||      }|S )z
    r   )linear_constraint)patsy.constraintrD   model
exog_names)model_resultstest_formularD   rG   LCs        r   make_hypotheses_matricesrK   i   s)     3$$//J	<	4BIr   )r   drop)statsmodels.tools.datatoolsdatar'   patsyr   r   r@   r   r$   r4   r;   r=   rB   rK   r   r   r   <module>rQ      s>    * * %  	3x 	36-r*
>r   