ó
ŕĆSc           @   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 7Z  d d
 l m	 Z	 e  d g 7Z  d d l
 m Z m Z m Z e  d d d g 7Z  d d l m Z e  d g 7Z  d d l m Z m Z m Z e  d d d g 7Z  d   Z d   Z d   Z d   Z d S(   t   It   Qi˙˙˙˙(   t   ContrastMatrixt	   Treatmentt   Polyt   Sumt   Helmertt   DiffR   R   R   R   R   R   (   t   CR   (   t   centert   standardizet   scaleR	   R
   R   (   t   bsR   (   t   crt   cct   teR   R   R   c         C   s   |  S(   s  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``.(    (   t   x(    (    s-   lib/python2.7/site-packages/patsy/builtins.pyR       s    c           C   s4   t  d  d k s t  t  d   d  k s0 t  d  S(   Ni   (   R    t   AssertionErrort   None(    (    (    s-   lib/python2.7/site-packages/patsy/builtins.pyt   test_I-   s    c         C   sY   d d l  m } | j d  } y | j |  SWn$ t k
 rT t d |  f   n Xd S(   s<  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"))
    i˙˙˙˙(   t   EvalEnvironmenti   s   no data named %r foundN(   t
   patsy.evalR   t   capturet	   namespacet   KeyErrort	   NameError(   t   nameR   t   env(    (    s-   lib/python2.7/site-packages/patsy/builtins.pyR   1   s    #c          C   sZ   d }  t  d  d k s t  t  d  t  k s6 t  d d l m } | t t  d  d  S(   Ni   t   aR   i˙˙˙˙(   t   assert_raisest   asdfsadfdsad(   R   R   t
   nose.toolsR   R   (   R   R   (    (    s-   lib/python2.7/site-packages/patsy/builtins.pyt   test_Q[   s
    N(   t   __all__t   patsy.contrastsR   R   R   R   R   R   t   patsy.categoricalR   t   patsy.stateR	   R
   R   t   patsy.splinesR   t   patsy.mgcv_cubic_splinesR   R   R   R    R   R   R    (    (    (    s-   lib/python2.7/site-packages/patsy/builtins.pyt   <module>   s   .			*