
    M/Ph                     p    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dS )    N)	dmatricesNAActionc                       e Zd Zd ZdS )r   c                     t          j        |d         j        d         t                    }|D ]}||z  }| || _        fd|D             S )Nr   )dtypec                 $    g | ]}|d f         S ). ).0v	good_masks     `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/formula/formulatools.py
<listcomp>z,NAAction._handle_NA_drop.<locals>.<listcomp>   s"    222a)S.!222    )npzerosshapeboolmissing_mask)selfvaluesis_NAsorigins
total_maskis_NAr   s         @r   _handle_NA_dropzNAAction._handle_NA_drop   sf    XfQioa0===
 	  	 E%JJK	&222262222r   N)__name__
__module____qualname__r   r	   r   r   r   r      s#        3 3 3 3 3r   r   dropc                 b   t          |t          t                                                              rt          t	          |                   S t          |          }|Ct          j        | |          rt          || |f|d|          }nUt          || |f|d|          }n>t          j        | d          rt          || |d|          }nt          || |d|          }t          |dd          }t          j        |          sd}t          |          dk    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   r0   s	            r   handle_formula_datar8      sj   2 '5!5!5!7!78899 .tG}}--w'''I}%a++ 	MwA+6)M M MFF wA+6)M M MFF %a.. 	4w5k)24 4 4FF w5k)24 4 4F 9nd;;L6, 
6{{QQi+<,,r   c                 D    ddl m} || v r|                     |           | S )z,
    Remove intercept from Patsy terms.
    r   	INTERCEPT)
patsy.descr;   remove)termsr;   s     r   _remove_intercept_patsyr?   Q   s8     %$$$$$EYLr   c                      ddl m} || j        v S )Nr   r:   )r<   r;   r>   )r0   r;   s     r   _has_interceptrA   [   s"    $$$$$$)))r   c                 T    ddl m ddlm}  |fd| j        D                       S )zR
    Returns boolean array index indicating which column holds the intercept.
    r   r:   )arrayc                     g | ]}|k    	S r	   r	   )r
   ir;   s     r   r   z"_intercept_idx.<locals>.<listcomp>f   s    <<<Q)q.<<<r   )r<   r;   numpyrC   r>   )r0   rC   r;   s     @r   _intercept_idxrG   `   sQ     %$$$$$5<<<<+*;<<<===r   c                 B    ddl m} | j        j        } |||          }|S )z
    r   )linear_constraint)patsy.constraintrI   model
exog_names)model_resultstest_formularI   rL   LCs        r   make_hypotheses_matricesrP   i   s8     322222$/J		<	4	4BIr   )r   r   )statsmodels.tools.datatoolsdatar+   patsyr   r   rF   r   r(   r8   r?   rA   rG   rP   r	   r   r   <module>rU      s    * * * * * * * * * % % % % % % % %     	3 	3 	3 	3 	3x 	3 	3 	36- 6- 6- 6-r  * * *
> > >    r   