σ
ΰΖχXc           @` s#  d  d l  m Z m Z m Z d  d l m Z d  d l m Z m Z m	 Z	 d  d l
 m Z d  d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d  d l m Z d  d l m Z d   Z d	 e f d
     YZ d   Z d e f d     YZ e d  Z  e d  Z! e d  Z" e d  Z# e d  Z$ e d  Z% e d i d  g d  6 Z& e d d d Z' e d d d Z( d   Z) e* d  Z+ e, d  Z- d d) d     YZ. d   Z/ d d* d      YZ0 d! e f d"     YZ1 d# d+ d$     YZ2 d% e3 f d&     YZ4 d'   Z5 d( S(,   i    (   t   absolute_importt   print_functiont   division(   t   Type(   t   Variablet   Applyt   Constant(   t   Op(   t   OpKeyOptimizert
   PatternSubt   TopoOptimizert   OpSubt   MergeOptimizert   configt   theanot   EquilibriumOptimizert   loggingt   pre_constant_merget   pre_greedy_local_optimizer(   t   FunctionGraph(   t   tensorc         C` s%   t  |  t  s! t d |    n  |  S(   Ns   not a Variable(   t
   isinstanceR   t	   TypeError(   t   x(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   as_variable   s    t   MyTypec           B` s#   e  Z d    Z d   Z d   Z RS(   c         C` s   | S(   N(    (   t   selft   data(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   filter   s    c         C` s   t  | t  S(   N(   R   R   (   R   t   other(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   __eq__   s    c         C` s
   t  t  S(   N(   t   hashR   (   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   __hash__   s    (   t   __name__t
   __module__R   R   R    (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR      s   		c         C` s   t  t   d  d  d |  S(   Nt   name(   R   R   t   None(   R#   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt
   MyVariable!   s    t   MyOpc           B` sD   e  Z d d d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C` s4   | |  _  | d  k r i  } n  | |  _ | |  _ d  S(   N(   R#   R$   t   destroy_mapR   (   R   R#   t   dmapR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   __init__'   s
    			c         G` sf   t  t t |   } x/ | D]' } t | j t  s t d   q q Wt     g } t |  | |  S(   Ns   Error 1(   t   listt   mapR   R   t   typeR   t	   ExceptionR   (   R   t   inputst   inputt   outputs(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt	   make_node.   s    c         C` s   |  j  S(   N(   R#   (   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   __str__6   s    c         C` s   |  j  S(   N(   R#   (   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   __repr__9   s    c         C` s@   |  | k p9 t  | t  o9 |  j d  k	 o9 |  j | j k } | S(   N(   R   R&   R   R$   (   R   R   t   rval(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR   <   s    <c         C` s*   |  j  d  k	 r t |  j   St |   Sd  S(   N(   R   R$   R   t   id(   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR    A   s    N(	   R!   R"   R$   R)   R1   R2   R3   R   R    (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR&   %   s   				t   Op1t   Op2t   Op3t   Op4t   Op5t   Op6t   OpDt   OpYR   i   t   OpZc          C` s1   t  d  }  t  d  } t  d  } |  | | f S(   NR   t   yt   z(   R%   (   R   R?   R@   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR.   U   s    c         C` s   t  t |  |  d | S(   Nt   ignore_newtrees(   R   R	   (   t   p1t   p2t   ign(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   PatternOptimizer\   s    c         C` s   t  t |  |  d | S(   NRA   (   R
   R	   (   RB   RC   RD   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   TopoPatternOptimizer`   s    t   TestPatternOptimizerc           B` s‘   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C` s   t    \ } } } t t | |  |  } t | | | g | g  } t t t d d f d f t d d f  j |  t |  d k s t  d  S(   Nt   1t   2t   3s   [Op4(z, y)](	   R.   t   op1t   op2R   RE   t   op4t   optimizet   strt   AssertionError(   R   R   R?   R@   t   et   g(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_replace_outputf   s    c         C` s   t    \ } } } t | |  } t | | | g | g  } t t d d f t t d f t d f t d d f f  j |  t |  d k s t	  d  S(   NRH   RI   s    [Op4(Op1(x), Op2(y), Op3(x, y))](
   R.   RK   R   RE   RM   RL   t   op3RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_nested_out_patterno   s    1c         C` s   t    \ } } } t t | |  |  } t | | | g | g  } t t t d d f d f t d d f  j |  t |  d k s t  d  S(   NRH   RI   s   [Op4(z, x)](	   R.   RK   RL   R   RE   RM   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_unification_1w   s    c         C` s   t    \ } } } t t | |  |  } t | | | g | g  } t t t d d f d f t d d f  j |  t |  d k s t  d  S(   NRH   RI   s   [Op1(Op2(x, y), z)](	   R.   RK   RL   R   RE   RM   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_unification_2   s    c         C` s   t    \ } } } t t | |  |  } t | | | g | g  } t t d d f t d d f  j |  t |  d k s t  d  S(   NRH   RI   s   [Op1(Op1(y, x), z)](   R.   RK   RL   R   RE   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_replace_subgraph   s    c         C` s   t    \ } } } t t | |  |  } t | | | g | g  } t t d d f t d d f d t j |  t |  d k s t  d  S(   NRH   RI   RD   s   [Op1(Op2(y, x), z)](	   R.   RK   RL   R   RE   t   TrueRN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_no_recurse   s    c         C` s   t    \ } } } t t | |  t | |  t | |   } t | | | g | g  } t t d d f t d f  j |  t |  d k s t  d  S(   NRH   RI   s   [Op1(Op4(x), Op4(x), Op4(y))](	   R.   RK   RL   R   RE   RM   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_multiple   s    -c         C` s   t    \ } } } t t t t |     } t | | | g | g  } t t t d f f d  j |  t |  d k s t  d  S(   NRH   s   [x](   R.   RK   R   RE   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_nested_even¦   s    c         C` s   t    \ } } } t t t t t |      } t | | | g | g  } t t t d f f d  j |  t |  d k s t  d  S(   NRH   s   [Op1(x)](   R.   RK   R   RE   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_nested_odd°   s    $c         C` s   t    \ } } } t t t |    } t | | | g | g  } t t d f t t d f f d t j |  t |  d k s t  d  S(   NRH   RD   s!   [Op2(Op1(Op2(Op1(Op2(Op1(x))))))](	   R.   RK   R   RE   RL   RY   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_expandΈ   s    "c         C` s   t    \ } } } t t t t t |      } t | | | g | g  } t t t d f f t d f d t j |  t |  d k s t  d  S(   NRH   RD   s   [Op1(x)](   R.   RK   R   RF   t   FalseRN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_ambiguousΐ   s    $c         C` s­   t  t   d d d } t d  } t  t   d d d } t t | |  |  } t | g | g  } t t | d f t d | f  j |  t |  d k s© t	  d  S(   Ni   R#   R   R?   R@   RH   s   [Op1(Op2(y, z), y)](
   R   R   R%   RK   R   RE   RL   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_constant_unificationΛ   s    c         C` s―   t    \ } } } t t t | |   t t | |    } t | | | g | g  } d   } t t i d d 6| d 6f t d f  j |  t |  d k s« t	  d  S(   Nc         S` s   |  j  j t k S(   N(   t   ownert   opRL   (   t   r(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt
   constraintΪ   s    RH   t   patternRe   s%   [Op4(Op3(Op2(x, y)), Op1(Op1(x, y)))](
   R.   RM   RK   RL   R   RE   RT   RN   RO   RP   (   R   R   R?   R@   RQ   RR   Re   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_constraintsΥ   s    -	
c         C` s   t    \ } } } t | |  } t | | | g | g  } t t d d f t d d f  j |  t |  d k s| t  d  S(   NR   R?   s   [Op3(x, x)](   R.   RK   R   RE   RT   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_match_sameβ   s    c         C` s©   t    \ } } } t t | |  t | |   } t | | | g | g  } d   } t i t d d f d 6| d 6t d d f  j |  t |  d k s₯ t  d  S(   Nc         S` s   |  j  j d |  j  j d k	 S(   Ni    i   (   Rb   R.   (   Rd   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyRe   ο   s    R   R?   Rf   Re   s   [Op2(Op1(x, x), Op3(x, y))](	   R.   RL   RK   R   RE   RT   RN   RO   RP   (   R   R   R?   R@   RQ   RR   Re   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_match_same_illegalκ   s    !	c         C` s   t    \ } } } t | |  } t t |  |  } t | | | g | g  } t t t d d f f t d d f  j |  t |  d k s t  d  S(   NR   R?   s   [Op3(Op4(*1 -> Op1(x, y)), *1)](	   R.   RK   RT   RM   R   RE   RN   RO   RP   (   R   R   R?   R@   t   e0RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt
   test_multiχ   s    c         C` s   t    \ } } } t t | |  |  } t | | | g | g  } t t t d d f d f t d d f  j |  t |  } | d k s t	  d  S(   NRH   RI   RJ   s   [Op4(z, y)](
   R.   RK   t   op_yR   RE   t   op_zRM   RN   RO   RP   (   R   R   R?   R@   RQ   RR   t   str_g(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_eq   s    (   R!   R"   RS   RU   RV   RW   RX   RZ   R[   R\   R]   R^   R`   Ra   Rg   Rh   Ri   Rk   Ro   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyRG   d   s"   													
				
					c         C` s   t  t |  |   S(   N(   R   R   (   RK   RL   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   OpSubOptimizer  s    t   TestOpSubOptimizerc           B` s   e  Z d    Z d   Z RS(   c         C` s   t    \ } } } t t t t t |      } t | | | g | g  } t t t  j |  t |  d k s t  d  S(   Ns   [Op2(Op2(Op2(Op2(Op2(x)))))](   R.   RK   R   Rp   RL   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_straightforward  s
    $c         C` s   t    \ } } } t t |  t |  t |   } t | | | g | g  } t t t  j |  t |  d k s t	  d  S(   Ns   [Op1(Op2(x), Op4(y), Op4(z))](
   R.   RK   RL   RT   RM   R   Rp   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_straightforward_2"  s
    $(   R!   R"   Rr   Rs   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyRq     s   	t	   NoInputOpc           B` s)   e  Z d Z d   Z d   Z d   Z RS(   t   paramc         C` s   | |  _  d  S(   N(   Ru   (   R   Ru   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR)   -  s    c         C` s   t  |  g  t     g  S(   N(   R   R   (   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR1   0  s    c         C` s   |  j  | d d <d  S(   Ni    (   Ru   (   R   t   nodeR.   t   output_storage(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   perform3  s    (   s   param(   R!   R"   t	   __props__R)   R1   Rx   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyRt   *  s   		t   TestMergeOptimizerc           B` s}   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z RS(   c         C` s   t    \ } } } t t | |  t | |  t | |   } t | | | g | g  } t   j |  t |  d k s t  d  S(   Ns%   [Op1(*1 -> Op2(x, y), *1, Op2(x, z))](   R.   RK   RL   R   R   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyRr   9  s
    -c         C` sΒ   t  d  } t t   d d d } t t   d d d } t t | |  t | |  t | |   } t | | | g | g  } t   j |  t |  } | d k sΎ | d k sΎ t	  d  S(   NR   i   R#   R?   R@   s   [Op1(*1 -> Op2(x, y), *1, *1)]s   [Op1(*1 -> Op2(x, z), *1, *1)](
   R%   R   R   RK   RL   R   R   RN   RO   RP   (   R   R   R?   R@   RQ   RR   t   strg(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_constant_merging@  s    -c         C` s   t    \ } } } t t t | |  |  t t t | |  |    } t | | | g | g  } t   j |  t |  d k s t	  d  S(   Ns'   [Op1(*1 -> Op3(Op2(x, y), z), Op4(*1))](
   R.   RK   RT   RL   RM   R   R   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_deep_mergeK  s
    9c         C` s   t    \ } } } t t t | |   t t | |    } t | | | g | g  } t   j |  t |  d k s t  d  S(   Ns%   [Op1(Op3(Op2(x, y)), Op3(Op2(y, x)))](	   R.   RK   RT   RL   R   R   RN   RO   RP   (   R   R   R?   R@   RQ   RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_no_mergeR  s
    -c         C` s   t    \ } } } t t | |   } t t | |   } t | | | g | | g  } t   j |  t |  d k s t  d  S(   Ns   [*1 -> Op3(Op2(x, y)), *1](   R.   RT   RL   R   R   RN   RO   RP   (   R   R   R?   R@   t   e1t   e2RR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_merge_outputsY  s    c   	      C` s³   t    \ } } } t | |  } t t |  | |  } t | t | |  t |   } t | | | g | g  } t   j |  t |  } | d k s― | d k s― t	  d  S(   NsA   [Op1(*1 -> Op1(x, y), Op4(*2 -> Op2(Op3(x), y, z), *1), Op1(*2))]sA   [Op1(*2 -> Op1(x, y), Op4(*1 -> Op2(Op3(x), y, z), *2), Op1(*1))](
   R.   RK   RL   RT   RM   R   R   RN   RO   RP   (	   R   R   R?   R@   R   R   RQ   RR   R{   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_multiple_mergesa  s    !c         C` sΗ   t  d  } t t   d d d } t t   d d d } t j } d t _ z t | |  } Wd  | t _ Xt | | | g | g  } t   j |  t	 |  } | d k sΓ | d k sΓ t
  d  S(	   NR   i   R#   R?   R@   t   offs   [Op1(y, y)]s   [Op1(z, z)](   R%   R   R   R   t   compute_test_valueRK   R   R   RN   RO   RP   (   R   R   R?   R@   t
   ctv_backupR   RR   R{   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_identical_constant_argsn  s    		
c         C` sΓ   t  j d  } t  j d  } t  j | |  t  j t  j j | | | k j    |  } t | | g | g  } t   j |  t	 j
 j | d d } d } | | k sΏ t | | f   d  S(   Nt   x1t   x2t   fileRO   s  Elemwise{add,no_inplace} [id A] ''   4
 |dot [id B] ''   3
 | |Assert{msg='Theano Assert failed!'} [id C] ''   2
 | | |x1 [id D]
 | | |All [id E] ''   1
 | |   |Elemwise{gt,no_inplace} [id F] ''   0
 | |     |x1 [id D]
 | |     |x2 [id G]
 | |x2 [id G]
 |dot [id B] ''   3
(   t   Tt   matrixt   dott   optt	   assert_opt   allR   R   RN   R   t   printingt
   debugprintRP   (   R   R   R   RQ   RR   R{   t   strref(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   est_one_assert_merge}  s    =c         C` sή   t  j d  } t  j d  } t  j t  j j | | | k j    |  t  j t  j j | | | k j    |  } t | | g | g  } t   j |  t	 j
 j | d d } d } | | k sΪ t | | f   d  S(   NR   R   R   RO   s  Elemwise{add,no_inplace} [id A] ''   4
 |dot [id B] ''   3
 | |Assert{msg='Theano Assert failed!'} [id C] ''   2
 | | |x1 [id D]
 | | |All [id E] ''   1
 | |   |Elemwise{gt,no_inplace} [id F] ''   0
 | |     |x1 [id D]
 | |     |x2 [id G]
 | |x2 [id G]
 |dot [id B] ''   3
(   R   R   R   R   R   R   R   R   RN   R   R   R   RP   (   R   R   R   RQ   RR   R{   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt    test_both_assert_merge_identical  s    *.c   	      C` s  t  j d  } t  j d  } t  j d  } t  j t  j j | | | k j    |  t  j t  j j | | | k j    |  } t | | | g | g  } t   j |  t	 j
 j | d d } d } d } | | k s| | k st | | | f   d  S(   NR   R   t   x3R   RO   s  Elemwise{add,no_inplace} [id A] ''   6
 |dot [id B] ''   5
 | |Assert{msg='Theano Assert failed!'} [id C] ''   4
 | | |x1 [id D]
 | | |All [id E] ''   3
 | | | |Elemwise{gt,no_inplace} [id F] ''   1
 | | |   |x1 [id D]
 | | |   |x3 [id G]
 | | |All [id H] ''   2
 | |   |Elemwise{gt,no_inplace} [id I] ''   0
 | |     |x1 [id D]
 | |     |x2 [id J]
 | |x2 [id J]
 |dot [id B] ''   5
s  Elemwise{add,no_inplace} [id A] ''   6
 |dot [id B] ''   5
 | |Assert{msg='Theano Assert failed!'} [id C] ''   4
 | | |x1 [id D]
 | | |All [id E] ''   3
 | | | |Elemwise{gt,no_inplace} [id F] ''   1
 | | |   |x1 [id D]
 | | |   |x2 [id G]
 | | |All [id H] ''   2
 | |   |Elemwise{gt,no_inplace} [id I] ''   0
 | |     |x1 [id D]
 | |     |x3 [id J]
 | |x2 [id G]
 |dot [id B] ''   5
(   R   R   R   R   R   R   R   R   RN   R   R   R   RP   (	   R   R   R   R   RQ   RR   R{   t   strref1t   strref2(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   est_both_assert_merge_1ͺ  s    *.c         C` sπ   t  j d  } t  j d  } t  j d  } t  j t  j j | | | k j    |  t  j | t  j j | | | k j     } t | | | g | g  } t   j |  t	 j
 j | d d } d } | | k sμ t | | f   d  S(   NR   R   R   R   RO   s·  Elemwise{add,no_inplace} [id A] ''   7
 |dot [id B] ''   6
 | |Assert{msg='Theano Assert failed!'} [id C] ''   5
 | | |x1 [id D]
 | | |All [id E] ''   3
 | |   |Elemwise{gt,no_inplace} [id F] ''   1
 | |     |x1 [id D]
 | |     |x3 [id G]
 | |Assert{msg='Theano Assert failed!'} [id H] ''   4
 |   |x2 [id I]
 |   |All [id J] ''   2
 |     |Elemwise{gt,no_inplace} [id K] ''   0
 |       |x2 [id I]
 |       |x3 [id G]
 |dot [id B] ''   6
(   R   R   R   R   R   R   R   R   RN   R   R   R   RP   (   R   R   R   R   RQ   RR   R{   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   est_both_assert_merge_2Φ  s    *.c         C` sϊ   t  j d  } t  j d  } t  j d  } t  j | t  j j | | | k j     t  j t  j j | | | k j    |  } t | | | g | g  } t   j |  t	 j
 j | d d } d } t |  | | k sφ t | | f   d  S(   NR   R   R   R   RO   s·  Elemwise{add,no_inplace} [id A] ''   7
 |dot [id B] ''   6
 | |Assert{msg='Theano Assert failed!'} [id C] ''   5
 | | |x1 [id D]
 | | |All [id E] ''   3
 | |   |Elemwise{gt,no_inplace} [id F] ''   1
 | |     |x1 [id D]
 | |     |x3 [id G]
 | |Assert{msg='Theano Assert failed!'} [id H] ''   4
 |   |x2 [id I]
 |   |All [id J] ''   2
 |     |Elemwise{gt,no_inplace} [id K] ''   0
 |       |x2 [id I]
 |       |x3 [id G]
 |dot [id B] ''   6
(   R   R   R   R   R   R   R   R   RN   R   R   R   t   printRP   (   R   R   R   R   RQ   RR   R{   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   est_both_assert_merge_2_reverseσ  s    *.
c         C` s±   t  d d    } t  d d    } t  d d    } t g  | | | g  } t   j |  g  | j D] } t | j t   rh | ^ qh } t |  d k s­ t | j   d  S(   NRu   i    i   i   (	   Rt   R   R   RN   t   apply_nodesR   Rc   t   lenRP   (   R   R   R?   R@   t   fgt   nt   no_input_ops(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_merge_noinput  s    (   R!   R"   Rr   R|   R}   R~   R   R   R   R   R   R   R   R   R‘   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyRz   7  s   										,		t   TestEquilibriumc           B` s8   e  Z d    Z d   Z e j j d d  d    Z RS(   c         C` sγ   t  t d  \ } } } t t | |   } t | | | g | g  } t t t d d f t d d f  t t d d f t d d f  t t t d d f f t d d f  g d d } | j	 |  t
 |  d k sί t  d  S(   Nt   xyzR   R?   t   max_use_ratioi
   s   [Op2(x, y)](   R+   R%   RT   RM   R   R   R	   RK   RL   RN   RO   RP   (   R   R   R?   R@   RQ   RR   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_1  s    *	c      
   C` s%  t  t d  \ } } } t t t | |    } t | | | g | g  } t t t t d d f f t d d f  t t d d f t d d f  t t d d f t	 d d f  t t	 d d f t
 d d f  t t
 d d f t d d f  g d d } | j |  t |  d k s!t  d  S(   NR£   R   R?   R€   i
   s   [Op2(x, y)](   R+   R%   RK   RT   R   R   R	   RL   RM   t   op5t   op6RN   RO   RP   (   R   R   R?   R@   RQ   RR   R   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_2.  s    $$	t   on_opt_errort   ignorec   	      C` s-  t  t d  \ } } } t t | |   } t | | | g | g  } t j d  } | j } | j t j	  z t
 t t d d f t d d f  t t d d f t d d f  t t t d d f f t d d f  g d d t | j  } | j |  Wd  | j |  Xt |  d k s)t  d  S(   NR£   s   theano.gof.optR   R?   R€   g      π?s   [Op1(x, y)](   R+   R%   RT   RM   R   R   t	   getLoggert   levelt   setLevelt   CRITICALR   R	   RK   RL   R   R   RN   RO   RP   (	   R   R   R?   R@   RQ   RR   t   _loggert   oldlevelR   (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_low_use_ratio>  s    	*(   R!   R"   R₯   R¨   R   t   configparsert   change_flagsR±   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyR’     s   		c          C` sά   t  j j j   d  }  t |  g  t  j j j d t  j j j d t d d  d   } t  j j	 j
   t  j j   d d g |  } t |  t t  j j j g |   } t | t  j j j  sΘ t  t | j    d  S(   Ni   R,   R   i   i   (   R   R   t
   type_othert	   MakeSliceR   t   SliceConstantt	   slicetypet   sliceR$   t	   subtensort   AdvancedSubtensorR   R   R   t   constant_foldingR   RP   R   t	   signature(   t   mst   const_slicet   advt   cst(    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   test_pre_constant_merge_sliceW  s    
N(    (    (    (6   t
   __future__R    R   R   t   theano.gof.typeR   t   theano.gof.graphR   R   R   t   theano.gof.opR   t   theano.gof.optR   R	   R
   R   R   R   R   R   R   R   R   t   theano.gof.fgR   R   R   R   R   R%   R&   RK   RL   RT   RM   R¦   R§   t   op_dRl   Rm   R.   R_   RE   RY   RF   RG   Rp   Rq   Rt   Rz   t   objectR’   RΑ   (    (    (    s9   /tmp/pip-build-X4mzal/theano/theano/gof/tests/test_opt.pyt   <module>   s:   L		$	±	ζ: