ó
àÆ÷Xc           @` sà  d  Z  d d l m Z m Z m Z d d l m Z m Z m Z m	 Z	 d d l
 m Z d d l
 m Z d d l Z d d d	 d
 d d g Z e rÿ d d l m Z e Z e Z e Z d „  Z d „  Z d „  Z d d l m Z m Z d „  Z d „  Z  d „  Z! n| d d l m Z d d l m" Z d d l# m Z m Z m Z d „  Z e Z d d l m Z m Z d „  Z d „  Z  d „  Z! e d d d d d  d! d" d# d$ d% g
 7Z d& e f d' „  ƒ  YZ$ e d& g 7Z d( „  Z% e d) g 7Z d S(*   s9   Code supporting compatibility across versions of Python.
i    (   t   absolute_importt   print_functiont   division(   t   PY3t   bt   BytesIOt   next(   t   configparser(   t   reload_moduleNR   R   R   R   R   t   reload(   t   truedivc         C` s*   |  j  d } t | t ƒ r& t | ƒ S| S(   Ni    (   t   argst
   isinstancet	   Exceptiont   exc_message(   t   et   msg(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR      s    
c         C` s   |  | k |  | k  S(   s,   Return -1 if x < y, 0 if x == y, 1 if x > y.(    (   t   xt   y(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt   cmp   s    c         C` s   t  |  d ƒ r |  j S|  S(   Nt   __func__(   t   hasattrR   (   t   unbound(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt   get_unbound_function    s    (   t   OrderedDictt   MutableMappingc         C` s
   |  j  ƒ  S(   N(   t   decode(   R   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR   *   s    c         c` s    x |  D] } | j  ƒ  Vq Wd  S(   N(   R   (   t   itrR   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt   decode_iter-   s    c         C` s   |  j  | ƒ S(   N(   R   (   R   t   encoding(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt   decode_with1   s    (   R   (   t   div(   t   izipt   imapt   ifilterc         C` s   |  d S(   Ni    (    (   R   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR   8   s    c         C` s   |  S(   N(    (   R   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR   ?   s    c         C` s   |  S(   N(    (   R   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR   B   s    c         C` s   |  S(   N(    (   R   R   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR   E   s    R   t   operator_divt	   DictMixinR   R   R   R   R!   R    R"   t   DefaultOrderedDictc           B` sA   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         O` sN   | d  k	 r. t | t j ƒ r. t d ƒ ‚ n  t j |  | | Ž | |  _ d  S(   Ns   first argument must be callable(   t   NoneR   t   collectionst   Callablet	   TypeErrorR   t   __init__t   default_factory(   t   selfR+   t   at   kw(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR*   M   s
    c         C` s6   y t  j |  | ƒ SWn t k
 r1 |  j | ƒ SXd  S(   N(   R   t   __getitem__t   KeyErrort   __missing__(   R,   t   key(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR/   T   s    c         C` s6   |  j  d  k r t | ƒ ‚ n  |  j  ƒ  |  | <} | S(   N(   R+   R&   R0   (   R,   R2   t   value(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR1   Z   s    c         C` sL   |  j  d  k r t ƒ  } n |  j  f } t |  ƒ | d  d  t |  j ƒ  ƒ f S(   N(   R+   R&   t   tuplet   typet   listt   items(   R,   R   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt
   __reduce__`   s    c         C` s
   |  j  ƒ  S(   N(   t   __copy__(   R,   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt   copyg   s    c         C` s   t  |  ƒ |  j |  ƒ S(   N(   R5   R+   (   R,   (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR9   j   s    N(	   t   __name__t
   __module__R&   R*   R/   R1   R8   R:   R9   (    (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyR%   L   s   				c         C` s   d d l  } | j j | ƒ r} yR | j |  j | j ƒ } | | k ro | j j | g | ƒ } | | j |  <n  Wq} q} Xn  d S(   s  Unfortunately, Conda offers to make itself the default Python
       and those who use it that way will probably not activate envs
       correctly meaning e.g. mingw-w64 g++ may not be on their PATH.

       This function ensures that, if `newpath` is an absolute path,
       and it is not already in os.environ[var] it gets added to the
       front.

       The reason we check first is because Windows environment vars
       are limited to 8191 characters and it is easy to hit that.

       `var` will typically be 'PATH'. i    N(   t   ost   patht   isabst   environt   splitt   pathsept   join(   t   vart   newpathR=   t   oldpathst   newpaths(    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt    maybe_add_to_os_environ_pathlistp   s    RH   (&   t   __doc__t
   __future__R    R   R   t   sixR   R   R   R   t	   six.movesR   R   R	   R'   t   __all__t   operatorR
   R#   t   zipR    t   mapR!   t   filterR"   R   R   R   R   R   R$   R   R   R   R   t	   itertoolsR%   RH   (    (    (    s6   /tmp/pip-build-X4mzal/theano/theano/compat/__init__.pyt   <module>   sB   "									!	