U
    ½mœd;  ã                   @   sÐ   d dgZ ddlmZmZmZmZmZmZ e dddddd	g7 Z dd
lm	Z	 e dg7 Z ddl
mZmZmZ e dddg7 Z ddlmZ e dg7 Z ddlmZmZmZ e dddg7 Z dd „ Zdd„ Zdd„ Zdd„ ZdS )ÚIÚQé    )ÚContrastMatrixÚ	TreatmentÚPolyÚSumÚHelmertÚDiffr   r   r   r   r   r	   )ÚCr
   )ÚcenterÚstandardizeÚscaler   r   r   )Úbsr   )ÚcrÚccÚter   r   r   c                 C   s   | S )a�  The identity function. Simply returns its input unchanged.

    Since Patsy's formula parser ignores anything inside a function call
    syntax, this is useful to 'hide' arithmetic operations from it. For
    instance::

      y ~ x1 + x2

    has ``x1`` and ``x2`` as two separate predictors. But in::

      y ~ I(x1 + x2)

    we instead have a single predictor, defined to be the sum of ``x1`` and
    ``x2``.© )Úxr   r   úG/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/patsy/builtins.pyr      s    c                   C   s$   t dƒdkst‚t d ƒd ks t‚d S )Né   )r   ÚAssertionErrorr   r   r   r   Útest_I-   s    r   c                 C   sJ   ddl m} | d¡}z|j|  W S  tk
rD   td| f ƒ‚Y nX dS )a<  A way to 'quote' variable names, especially ones that do not otherwise
    meet Python's variable name rules.

    If ``x`` is a variable, ``Q("x")`` returns the value of ``x``. (Note that
    ``Q`` takes the *string* ``"x"``, not the value of ``x`` itself.) This
    works even if instead of ``x``, we have a variable name that would not
    otherwise be legal in Python.

    For example, if you have a column of data named ``weight.in.kg``, then you
    can't write::

      y ~ weight.in.kg

    because Python will try to find a variable named ``weight``, that has an
    attribute named ``in``, that has an attribute named ``kg``. (And worse
    yet, ``in`` is a reserved word, which makes this example doubly broken.)
    Instead, write::

      y ~ Q("weight.in.kg")

    and all will be well. Note, though, that this requires embedding a Python
    string inside your formula, which may require some care with your quote
    marks. Some standard options include::

      my_fit_function("y ~ Q('weight.in.kg')", ...)
      my_fit_function('y ~ Q("weight.in.kg")', ...)
      my_fit_function("y ~ Q(\"weight.in.kg\")", ...)

    Note also that ``Q`` is an ordinary Python function, which means that you
    can use it in more complex expressions. For example, this is a legal
    formula::

      y ~ np.sqrt(Q("weight.in.kg"))
    r   )ÚEvalEnvironmentr   zno data named %r foundN)Z
patsy.evalr   ÚcaptureÚ	namespaceÚKeyErrorÚ	NameError)Únamer   Úenvr   r   r   r   1   s    #
c                  C   s>   d} t dƒdkst‚t dƒt ks$t‚dd l}| tt d¡ d S )Nr   Úar   r   Zasdfsadfdsad)r   r   ÚpytestZraisesr   )r   r    r   r   r   Útest_Q[   s
    r!   N)Ú__all__Zpatsy.contrastsr   r   r   r   r   r	   Zpatsy.categoricalr
   Zpatsy.stater   r   r   Zpatsy.splinesr   Zpatsy.mgcv_cubic_splinesr   r   r   r   r   r   r!   r   r   r   r   Ú<module>   s    

*