
    J/PhE                         d dgZ ddlmZmZmZmZmZmZ e g dz  Z ddlm	Z	 e dgz  Z ddl
mZmZmZ e g dz  Z ddlmZ e dgz  Z dd	lmZmZmZ e g d	z  Z d
 Zd Zd Zd ZdS )IQ    )ContrastMatrix	TreatmentPolySumHelmertDiff)Cr   )centerstandardizescale)bsr   )crcctec                     | 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``. )xs    N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/patsy/builtins.pyr   r   "   s	     H    c                  R    t          d          dk    sJ t          d           J d S )N   )r   r   r   r   test_Ir   4   s(    Q4419999T77?????r   c                     ddl m} |                    d          }	 |j        |          S # t          $ r t          d| d          w xY w)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 z found)
patsy.evalr   capture	namespaceKeyError	NameError)namer   envs      r   r   r   9   sn    F +*****

!
!!
$
$C<}T"" < < <iDDD:;;;<s	   * Ac                      d} t          d          dk    sJ t          d          t           u sJ dd l}|                    t          t           d           d S )Nr   ar   r   asdfsadfdsad)r   pytestraisesr!   )r%   r'   s     r   test_Qr)   e   sR    	AS66Q;;;;S66Q;;;;MMM
MM)Q/////r   N)__all__patsy.contrastsr   r   r   r   r	   r
   patsy.categoricalr   patsy.stater   r   r   patsy.splinesr   patsy.mgcv_cubic_splinesr   r   r   r   r   r   r)   r   r   r   <module>r0      s2   * O O O O O O O O O O O O O O O O LLL L       C5  2 2 2 2 2 2 2 2 2 2 --- -       D6  / / / / / / / / / /    $  
)< )< )<X0 0 0 0 0r   