ó
àÆ÷Xc           @` sÐ   d  Z  d d l m Z m Z m Z d d l Z d d l m Z	 d d l
 m Z d d l
 Z
 d d l m Z m Z d d l m Z d d l Z e e e g e ƒ d „  ƒ Z d	 e	 j f d
 „  ƒ  YZ d „  Z d S(   s   
 Tests for the Op decorator
i    (   t   absolute_importt   print_functiont   divisionN(   t   unittest_tools(   t   function(   t   dmatrixt   dvector(   t   as_opc         C` s   |  | S(   N(    (   t   at   b(    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   mul   s    t   OpDecoratorTestsc           B` s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C` s   t  d ƒ } t t  t ƒ d „  ƒ } t | g | | ƒ ƒ } | d d g d d g g ƒ } t j d d d d g ƒ } t j | | ƒ s™ t | | f ƒ ‚ d  S(	   Nt   xc         S` s   t  j |  ƒ S(   N(   t   npt   cumprod(   R   (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyR      s    g      ø?i   i   g      @g      .@g      >@(   R   R   R   R   R   t   arrayt   allcloset   AssertionError(   t   selfR   R   t   fnt   rt   r0(    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt	   test_1arg   s    c         C` së   t  d ƒ } t j d ƒ | j _ t d ƒ } d d g | j _ t t  t g t ƒ d „  ƒ } t | | g | | | ƒ ƒ } | d d g d d g g d d	 d d
 g ƒ } t j d d d d g ƒ } t j	 | | ƒ sç t
 | | f ƒ ‚ d  S(   NR   i   t   yi    c         S` s   t  j |  ƒ | S(   N(   R   R   (   R   R   (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   cumprod_plus,   s    g      ø?i   i   id   iÈ   g      @g     àZ@g      1@g     Àl@(   i   i   (   R   R   t   zerost   tagt
   test_valueR   R   R   R   R   R   (   R   R   R   R   R   R   R   (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt	   test_2arg&   s    -c         C` sÂ   t  d ƒ } t j d ƒ | j _ t d ƒ } d d g | j _ d „  } t t  t g t | ƒ d „  ƒ } |  j | | g | | | ƒ g d d g d d g g d	 d
 d d g g | j d t	 ƒd  S(   NR   i   R   i    c         S` s   | \ } } | g S(   N(    (   t   nodet   shapesR   R   (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   infer_shape<   s    c         S` s   t  j |  ƒ | S(   N(   R   R   (   R   R   (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyR   @   s    g      ø?i   i   id   iÈ   t   warn(   i   i   (
   R   R   R   R   R   R   R   t   _compile_and_checkt	   __class__t   False(   R   R   R   R   R   (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   test_infer_shape6   s    	!'c         C` sg   t  d ƒ } t  d ƒ } t | | ƒ } t j | ƒ } t j | ƒ } | j j | j j k sc t ‚ d  S(   NR   R   (   R   R
   t   picklet   dumpst   loadst   ownert   opR   (   R   R   R   t   mt   st   m2(    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   test_pickleH   s    (   t   __name__t
   __module__R   R   R$   R-   (    (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyR      s   			c           C` s7   t  t j j j t j d ƒ ƒ j ƒ  t ƒ s3 t	 ‚ d  S(   Ni   (
   t
   isinstancet   theanot   tensort   optt   Shape_iR   t   int64t   __hash__t   intR   (    (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   test_shape_i_hashT   s    (   t   __doc__t
   __future__R    R   R   t   numpyR   t   theano.testsR   t   uttR1   R   t   theano.tensorR   R   t   theano.compileR   R%   R
   t   InferShapeTesterR   R8   (    (    (    s=   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_ops.pyt   <module>   s   =