ó
àÆ÷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 Z d d l	 m
 Z
 d d l Z d d l j Z d d l m Z m 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 S(   s!   
Tests of printing functionality
i    (   t   absolute_importt   print_functiont   divisionN(   t   SkipTest(   t   StringIO(   t   min_informative_strt
   debugprintc          C` s  t  j j s t d ƒ ‚ n  t j ƒ  }  t  j |  g |  d ƒ } | d d d d g ƒ t ƒ  } t j	 | ƒ } | j
 t j ƒ t  j } t  j j | ƒ t  j j | ƒ z  t  j j | d t d t ƒWd t  j j | ƒ t  j j | ƒ X| j ƒ  d	 k st ‚ d S(
   sM   
    This is a REALLY PARTIAL TEST.

    I did them to help debug stuff.
    s   pydot not availablei   i   i   i   t   cond_highlightt   print_output_fileNsK   pydotprint: cond_highlight is set but there is no IfElse node in the graph
(   t   theanot   printingt   pydot_importedR   t   tensort   dvectort   functionR   t   loggingt   StreamHandlert   setLevelt   DEBUGt   logging_default_handlert   theano_loggert   removeHandlert
   addHandlert
   pydotprintt   Truet   Falset   getvaluet   AssertionError(   t   xt   ft   st   new_handlert   orig_handler(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_pydotprint_cond_highlight   s"    		c          C` sb   t  j j s t d ƒ ‚ n  t j ƒ  }  t  j j |  d d t ƒ} t | t	 t
 f ƒ s^ t ‚ d  S(   Ns   pydot not availablei   t   return_image(   R	   R
   R   R   R   R   R   R   t
   isinstancet   strt   bytesR   (   R   t   ret(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_pydotprint_return_image3   s
    c          C` sË   t  j j s t d ƒ ‚ n  t j ƒ  }  t  j j j ƒ  j	 d ƒ } t  j
 |  g |  d |  |  g d | ƒ} | d d d d g ƒ t  j j | d d	 d
 t ƒt  j j |  d |  |  g d d	 d
 t ƒd S(   sÛ   This is a REALLY PARTIAL TEST.

    It prints a graph where there are variable and apply nodes whose long
    names are different, but not the shortened names.
    We should not merge those nodes in the dot graph.

    s   pydot not availablet   fusioni   t   modei   i   i   t   max_label_sizei   R   N(   R	   R
   R   R   R   R   t   compileR)   t   get_default_modet	   excludingR   R   R   (   R   R)   R   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_pydotprint_long_name=   s    
)c          C` s¡   t  j j s t d ƒ ‚ n  t j ƒ  }  t  j j d t d t ƒ } t  j	 |  g |  d d | ƒ} t  j j
 | d t ƒ| d g g ƒ t  j j
 | d t ƒd S(   s7   Just check that pydotprint does not crash with profile.s   pydot not availablet   atexit_printt
   gpu_checksi   t   profileR   N(   R	   R
   R   R   R   t   matrixR+   t   ProfileStatsR   R   R   (   t   At   profR   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_pydotprint_profileV   s    c    	      C` sÖ   t  j d d ƒ }  t  j d d ƒ } |  | } d | _ t  j d d ƒ } t  j d d ƒ } | | } | | } t | ƒ j d d ƒ } d	 } | | k rÀ t d
 | d
 ƒ t d
 | d
 ƒ n  | | k sÒ t ‚ d S(   sf    evaluates a reference output to make sure the
        min_informative_str function works as intended t   nameR4   t   Bt   Ct   Dt   Es   	s           sL   A. Elemwise{add,no_inplace}
 B. C
 C. Elemwise{add,no_inplace}
  D. D
  E. Es   --N(   R   R2   R7   R   t   replacet   printR   (	   R4   R8   R9   R:   R;   t   Ft   Gt   mist	   reference(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_min_informative_stre   s    
	

c          C` sˆ  t  j d d ƒ }  t  j d d ƒ } |  | } d | _ t  j d d ƒ } t  j d d ƒ } | | } | | } t j j ƒ  j d ƒ } t j |  | | | g | d | ƒ} t ƒ  }	 t	 | d	 |	 ƒt ƒ  }	 t	 | d	 |	 d
 d ƒ|	 j
 ƒ  }	 d j d d d d d d d g ƒ d }
 |	 |
 k rJt d |	 d ƒ t d |
 d ƒ n  |	 |
 k s\t ‚ t ƒ  }	 t	 | d	 |	 d
 d ƒ|	 j
 ƒ  }	 d j d d d d d d d g ƒ d }
 |	 |
 k rât d |	 d ƒ t d |
 d ƒ n  |	 |
 k sôt ‚ t ƒ  }	 t	 | d	 |	 d
 d d t ƒ|	 j
 ƒ  }	 d j d d d d d  g ƒ d }
 |	 |
 k rzt d |	 d ƒ t d |
 d ƒ n  |	 |
 k sŒt ‚ t ƒ  }	 t	 | d	 |	 d
 d! ƒ|	 j
 ƒ  }	 d j d" d# d$ d% d& d' d( g ƒ d }
 |	 |
 k rt d |	 d ƒ t d |
 d ƒ n  |	 |
 k s$t ‚ t ƒ  }	 t	 | d	 |	 d
 d! d) t ƒ|	 j
 ƒ  }	 d j d* d+ d, d- d. g ƒ d }
 |	 |
 k rªt d |	 d ƒ t d |
 d ƒ n  |	 |
 k s¼t ‚ t ƒ  }	 t j |  | | g |  | |  | | g d d/ ƒ} t	 | d	 |	 d0 t ƒ|	 j
 ƒ  }	 d j d1 d2 d3 d4 d5 d6 g ƒ d }
 |	 |
 k rrt d |	 d ƒ t d |
 d ƒ n  |	 |
 k s„t ‚ d  S(7   NR7   R4   R8   R9   R:   R;   R(   R)   t   filet   idst   ints   
s%   Elemwise{add,no_inplace} [id 0] ''   s(    |Elemwise{add,no_inplace} [id 1] 'C'   s    | |A [id 2]s    | |B [id 3]s'    |Elemwise{add,no_inplace} [id 4] ''   s      |D [id 5]s      |E [id 6]s   --t   CHARs%   Elemwise{add,no_inplace} [id A] ''   s(    |Elemwise{add,no_inplace} [id B] 'C'   s    | |A [id C]s    | |B [id D]s'    |Elemwise{add,no_inplace} [id E] ''   s      |D [id F]s      |E [id G]t   stop_on_names'    |Elemwise{add,no_inplace} [id C] ''   s      |D [id D]s      |E [id E]t    s   Elemwise{add,no_inplace}  ''   s"    |Elemwise{add,no_inplace}  'C'   s    | |A s    | |B s!    |Elemwise{add,no_inplace}  ''   s      |D s      |E t   print_storages'   Elemwise{add,no_inplace}  ''   0 [None]s    |A  [None]s    |B  [None]s    |D  [None]s    |E  [None]t   FAST_COMPILEt   print_clientssN   Elemwise{add,no_inplace} [id A] ''   0 clients:[('[id B]', 1), ('output', '')]s
    |A [id D]s
    |B [id E]s&   Elemwise{sub,no_inplace} [id B] ''   1sP    |Elemwise{add,no_inplace} [id A] ''   0 clients:[('[id B]', 1), ('output', '')]s
    |D [id F](   R   R2   R7   R	   R+   R,   t	   includingR   R   R   R   t   joinR=   R   R   (   R4   R8   R9   R:   R;   R>   R?   R)   t   gR   RA   R   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_debugprint‚   sÒ    
	

$												*		c       	   C` sô   t  j d ƒ }  t  j d ƒ } t j d d „  d t  j | ƒ d | d |  ƒ \ } } | d } t j j | d	 d
 ƒ} g  } x$ | j d ƒ D] } | | g 7} qŒ Wd } xD t	 | j d ƒ | ƒ D]* \ }	 }
 |	 j
 ƒ  |
 j
 ƒ  k sÂ t ‚ qÂ Wd  S(   Nt   kR4   t   fnc         S` s   |  | S(   N(    (   t   prior_resultR4   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   <lambda>  s    t   outputs_infot   non_sequencest   n_stepsiÿÿÿÿRC   R$   s   
sÛ  Subtensor{int64} [id A] ''
     |Subtensor{int64::} [id B] ''
     | |for{cpu,scan_fn} [id C] ''
     | | |k [id D]
     | | |IncSubtensor{Set;:int64:} [id E] ''
     | | | |AllocEmpty{dtype='float64'} [id F] ''
     | | | | |Elemwise{add,no_inplace} [id G] ''
     | | | | | |k [id D]
     | | | | | |Subtensor{int64} [id H] ''
     | | | | |   |Shape [id I] ''
     | | | | |   | |Rebroadcast{0} [id J] ''
     | | | | |   |   |InplaceDimShuffle{x,0} [id K] ''
     | | | | |   |     |Elemwise{second,no_inplace} [id L] ''
     | | | | |   |       |A [id M]
     | | | | |   |       |InplaceDimShuffle{x} [id N] ''
     | | | | |   |         |TensorConstant{1.0} [id O]
     | | | | |   |Constant{0} [id P]
     | | | | |Subtensor{int64} [id Q] ''
     | | | |   |Shape [id R] ''
     | | | |   | |Rebroadcast{0} [id J] ''
     | | | |   |Constant{1} [id S]
     | | | |Rebroadcast{0} [id J] ''
     | | | |ScalarFromTensor [id T] ''
     | | |   |Subtensor{int64} [id H] ''
     | | |A [id M]
     | |Constant{1} [id U]
     |Constant{-1} [id V]

    Inner graphs of the scan ops:

    for{cpu,scan_fn} [id C] ''
     >Elemwise{mul,no_inplace} [id W] ''
     > |<TensorType(float64, vector)> [id X] -> [id E]
     > |A_copy [id Y] -> [id M](   R   t   iscalarR   R	   t   scant	   ones_likeR
   R   t   splitt   zipt   stripR   (   RP   R4   t   resultt   updatest   final_resultt
   output_strt   linest   linet   expected_outputt   trutht   out(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_scan_debugprint1  s    
#%c       	   C` s  t  j j d ƒ }  t j d ƒ } d } t  j d d „  d d  d |  t  j j | ƒ g d | ƒ \ } } | j ƒ  } t  j j	 | d	 d
 ƒ} g  } x$ | j
 d ƒ D] } | | g 7} q  Wd }	 xD t |	 j
 d ƒ | ƒ D]* \ }
 } |
 j ƒ  | j ƒ  k sÖ t ‚ qÖ Wd  S(   Nt   coefficientsR   i'  RQ   c         S` s   |  | | S(   N(    (   t   coefficientt   powert   free_variable(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyRS   K  s    RT   t	   sequencesRU   RC   R$   s   
sh  Sum{acc_dtype=float64} [id A] ''
     |for{cpu,scan_fn} [id B] ''
       |Elemwise{minimum,no_inplace} [id C] ''
       | |Subtensor{int64} [id D] ''
       | | |Shape [id E] ''
       | | | |Subtensor{int64::} [id F] 'coefficients[0:]'
       | | |   |coefficients [id G]
       | | |   |Constant{0} [id H]
       | | |Constant{0} [id I]
       | |Subtensor{int64} [id J] ''
       |   |Shape [id K] ''
       |   | |Subtensor{int64::} [id L] ''
       |   |   |ARange{dtype='int64'} [id M] ''
       |   |   | |TensorConstant{0} [id N]
       |   |   | |TensorConstant{10000} [id O]
       |   |   | |TensorConstant{1} [id P]
       |   |   |Constant{0} [id Q]
       |   |Constant{0} [id R]
       |Subtensor{:int64:} [id S] ''
       | |Subtensor{int64::} [id F] 'coefficients[0:]'
       | |ScalarFromTensor [id T] ''
       |   |Elemwise{minimum,no_inplace} [id C] ''
       |Subtensor{:int64:} [id U] ''
       | |Subtensor{int64::} [id L] ''
       | |ScalarFromTensor [id V] ''
       |   |Elemwise{minimum,no_inplace} [id C] ''
       |Elemwise{minimum,no_inplace} [id C] ''
       |x [id W]

    Inner graphs of the scan ops:

    for{cpu,scan_fn} [id B] ''
     >Elemwise{mul,no_inplace} [id X] ''
     > |coefficients[t] [id Y] -> [id S]
     > |Elemwise{pow,no_inplace} [id Z] ''
     >   |x_copy [id BA] -> [id W]
     >   |<TensorType(int64, scalar)> [id BB] -> [id U](   R	   R   t   vectort   scalarRX   t   Nonet   aranget   sumR
   R   RZ   R[   R\   R   (   Rg   R   t   max_coefficients_supportedt
   componentsR^   t
   polynomialR`   Ra   Rb   Rc   Rd   Re   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_scan_debugprint2D  s"    	&%c       
   ` s2  t  j j d ƒ }  d } t j d ƒ } t j d ƒ } d „  ‰  t  j d ‡  f d †  d d  d	 |  t  j j | ƒ g d
 | | g ƒ \ } } | j ƒ  } | } t  j j	 | d d ƒ} g  }	 x$ | j
 d ƒ D] }
 |	 |
 g 7}	 qÊ Wd } xD t | j
 d ƒ |	 ƒ D]* \ } } | j ƒ  | j ƒ  k s t ‚ q Wd  S(   NRg   i
   RP   R4   c      	   S` sD   t  j d d „  d t j |  ƒ d |  d | ƒ \ } } | d } | S(   NRQ   c         S` s   |  | S(   N(    (   RR   R4   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyRS     s    RT   RU   RV   iÿÿÿÿ(   R	   RX   R   RY   (   R4   RP   R]   R^   t   A_k(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   compute_A_kŽ  s    
RQ   c         ` s   |  ˆ  | | ƒ | S(   N(    (   Rh   Ri   t   some_At   some_k(   Rv   (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyRS   ›  s    RT   Rk   RU   RC   R$   s   
sf  Sum{acc_dtype=float64} [id A] ''
     |for{cpu,scan_fn} [id B] ''
       |Elemwise{minimum,no_inplace} [id C] ''
       | |Subtensor{int64} [id D] ''
       | | |Shape [id E] ''
       | | | |Subtensor{int64::} [id F] 'coefficients[0:]'
       | | |   |coefficients [id G]
       | | |   |Constant{0} [id H]
       | | |Constant{0} [id I]
       | |Subtensor{int64} [id J] ''
       |   |Shape [id K] ''
       |   | |Subtensor{int64::} [id L] ''
       |   |   |ARange{dtype='int64'} [id M] ''
       |   |   | |TensorConstant{0} [id N]
       |   |   | |TensorConstant{10} [id O]
       |   |   | |TensorConstant{1} [id P]
       |   |   |Constant{0} [id Q]
       |   |Constant{0} [id R]
       |Subtensor{:int64:} [id S] ''
       | |Subtensor{int64::} [id F] 'coefficients[0:]'
       | |ScalarFromTensor [id T] ''
       |   |Elemwise{minimum,no_inplace} [id C] ''
       |Subtensor{:int64:} [id U] ''
       | |Subtensor{int64::} [id L] ''
       | |ScalarFromTensor [id V] ''
       |   |Elemwise{minimum,no_inplace} [id C] ''
       |Elemwise{minimum,no_inplace} [id C] ''
       |A [id W]
       |k [id X]

    Inner graphs of the scan ops:

    for{cpu,scan_fn} [id B] ''
     >Elemwise{mul,no_inplace} [id Y] ''
     > |InplaceDimShuffle{x} [id Z] ''
     > | |coefficients[t] [id BA] -> [id S]
     > |Elemwise{pow,no_inplace} [id BB] ''
     >   |Subtensor{int64} [id BC] ''
     >   | |Subtensor{int64::} [id BD] ''
     >   | | |for{cpu,scan_fn} [id BE] ''
     >   | | | |k_copy [id BF] -> [id X]
     >   | | | |IncSubtensor{Set;:int64:} [id BG] ''
     >   | | | | |AllocEmpty{dtype='float64'} [id BH] ''
     >   | | | | | |Elemwise{add,no_inplace} [id BI] ''
     >   | | | | | | |k_copy [id BF] -> [id X]
     >   | | | | | | |Subtensor{int64} [id BJ] ''
     >   | | | | | |   |Shape [id BK] ''
     >   | | | | | |   | |Rebroadcast{0} [id BL] ''
     >   | | | | | |   |   |InplaceDimShuffle{x,0} [id BM] ''
     >   | | | | | |   |     |Elemwise{second,no_inplace} [id BN] ''
     >   | | | | | |   |       |A_copy [id BO] -> [id W]
     >   | | | | | |   |       |InplaceDimShuffle{x} [id BP] ''
     >   | | | | | |   |         |TensorConstant{1.0} [id BQ]
     >   | | | | | |   |Constant{0} [id BR]
     >   | | | | | |Subtensor{int64} [id BS] ''
     >   | | | | |   |Shape [id BT] ''
     >   | | | | |   | |Rebroadcast{0} [id BL] ''
     >   | | | | |   |Constant{1} [id BU]
     >   | | | | |Rebroadcast{0} [id BL] ''
     >   | | | | |ScalarFromTensor [id BV] ''
     >   | | | |   |Subtensor{int64} [id BJ] ''
     >   | | | |A_copy [id BO] -> [id W]
     >   | | |Constant{1} [id BW]
     >   | |Constant{-1} [id BX]
     >   |InplaceDimShuffle{x} [id BY] ''
     >     |<TensorType(int64, scalar)> [id BZ] -> [id U]

    for{cpu,scan_fn} [id BE] ''
     >Elemwise{mul,no_inplace} [id CA] ''
     > |<TensorType(float64, vector)> [id CB] -> [id BG]
     > |A_copy [id CC] -> [id BO](   R	   R   R   RW   RX   Rn   Ro   Rp   R
   R   RZ   R[   R\   R   (   Rg   Rq   RP   R4   Rr   R^   Rs   R_   R`   Ra   Rb   Rc   Rd   Re   (    (   Rv   s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_scan_debugprint3†  s(    		H%c          C` s:  d „  }  t  j t j d d d ƒƒ } t  j t j d d d ƒƒ } t  j |  d i | d 6d d g d	 6i | d 6d d g d	 6g d
 d ƒ\ \ } } } | | } t  j j | d d ƒ} g  } x$ | j d ƒ D] }	 | |	 g 7} qÒ Wd }
 xD t |
 j d ƒ | ƒ D]* \ } } | j	 ƒ  | j	 ƒ  k st
 ‚ qWd  S(   Nc         S` s   | |  | | f S(   N(    (   t   a_m2t   a_m1t   b_m2t   b_m1(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyRQ   ý  s    i   t   dtypet   int64RT   t   initialiþÿÿÿiÿÿÿÿt   tapsRV   i   RC   R$   s   
s_  Elemwise{add,no_inplace} [id A] ''
     |Subtensor{int64::} [id B] ''
     | |for{cpu,scan_fn}.0 [id C] ''
     | | |TensorConstant{5} [id D]
     | | |IncSubtensor{Set;:int64:} [id E] ''
     | | | |AllocEmpty{dtype='int64'} [id F] ''
     | | | | |Elemwise{add,no_inplace} [id G] ''
     | | | |   |TensorConstant{5} [id D]
     | | | |   |Subtensor{int64} [id H] ''
     | | | |     |Shape [id I] ''
     | | | |     | |Subtensor{:int64:} [id J] ''
     | | | |     |   |<TensorType(int64, vector)> [id K]
     | | | |     |   |Constant{2} [id L]
     | | | |     |Constant{0} [id M]
     | | | |Subtensor{:int64:} [id J] ''
     | | | |ScalarFromTensor [id N] ''
     | | |   |Subtensor{int64} [id H] ''
     | | |IncSubtensor{Set;:int64:} [id O] ''
     | |   |AllocEmpty{dtype='int64'} [id P] ''
     | |   | |Elemwise{add,no_inplace} [id Q] ''
     | |   |   |TensorConstant{5} [id D]
     | |   |   |Subtensor{int64} [id R] ''
     | |   |     |Shape [id S] ''
     | |   |     | |Subtensor{:int64:} [id T] ''
     | |   |     |   |<TensorType(int64, vector)> [id U]
     | |   |     |   |Constant{2} [id V]
     | |   |     |Constant{0} [id W]
     | |   |Subtensor{:int64:} [id T] ''
     | |   |ScalarFromTensor [id X] ''
     | |     |Subtensor{int64} [id R] ''
     | |Constant{2} [id Y]
     |Subtensor{int64::} [id Z] ''
       |for{cpu,scan_fn}.1 [id C] ''
       |Constant{2} [id BA]

    Inner graphs of the scan ops:

    for{cpu,scan_fn}.0 [id C] ''
     >Elemwise{add,no_inplace} [id BB] ''
     > |<TensorType(int64, scalar)> [id BC] -> [id E]
     > |<TensorType(int64, scalar)> [id BD] -> [id E]
     >Elemwise{add,no_inplace} [id BE] ''
     > |<TensorType(int64, scalar)> [id BF] -> [id O]
     > |<TensorType(int64, scalar)> [id BG] -> [id O]

    for{cpu,scan_fn}.1 [id C] ''
     >Elemwise{add,no_inplace} [id BB] ''
     >Elemwise{add,no_inplace} [id BE] ''(   R	   t   sharedt   numpyRo   RX   R
   R   RZ   R[   R\   R   (   RQ   t   a0t   b0t   at   bt   _R_   R`   Ra   Rb   Rc   Rd   Re   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_scan_debugprint4û  s    	
1%c       	   C` s  t  j d ƒ }  t  j d ƒ } t j d d „  d t  j | ƒ d | d |  ƒ \ } } t  j | d j ƒ  | ƒ } t j j	 | d	 d
 ƒ} g  } x$ | j
 d ƒ D] } | | g 7} qž Wd } xD t | j
 d ƒ | ƒ D]* \ }	 }
 |	 j ƒ  |
 j ƒ  k sÔ t ‚ qÔ Wd  S(   NRP   R4   RQ   c         S` s   |  | S(   N(    (   RR   R4   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyRS   I  s    RT   RU   RV   iÿÿÿÿRC   R$   s   
sï  Subtensor{int64} [id A] ''
    |for{cpu,grad_of_scan_fn}.1 [id B] ''
    | |Elemwise{sub,no_inplace} [id C] ''
    | | |Subtensor{int64} [id D] ''
    | | | |Shape [id E] ''
    | | | | |for{cpu,scan_fn} [id F] ''
    | | | |   |k [id G]
    | | | |   |IncSubtensor{Set;:int64:} [id H] ''
    | | | |   | |AllocEmpty{dtype='float64'} [id I] ''
    | | | |   | | |Elemwise{add,no_inplace} [id J] ''
    | | | |   | | | |k [id G]
    | | | |   | | | |Subtensor{int64} [id K] ''
    | | | |   | | |   |Shape [id L] ''
    | | | |   | | |   | |Rebroadcast{0} [id M] ''
    | | | |   | | |   |   |InplaceDimShuffle{x,0} [id N] ''
    | | | |   | | |   |     |Elemwise{second,no_inplace} [id O] ''
    | | | |   | | |   |       |A [id P]
    | | | |   | | |   |       |InplaceDimShuffle{x} [id Q] ''
    | | | |   | | |   |         |TensorConstant{1.0} [id R]
    | | | |   | | |   |Constant{0} [id S]
    | | | |   | | |Subtensor{int64} [id T] ''
    | | | |   | |   |Shape [id U] ''
    | | | |   | |   | |Rebroadcast{0} [id M] ''
    | | | |   | |   |Constant{1} [id V]
    | | | |   | |Rebroadcast{0} [id M] ''
    | | | |   | |ScalarFromTensor [id W] ''
    | | | |   |   |Subtensor{int64} [id K] ''
    | | | |   |A [id P]
    | | | |Constant{0} [id X]
    | | |TensorConstant{1} [id Y]
    | |Subtensor{:int64:} [id Z] ''
    | | |Subtensor{::int64} [id BA] ''
    | | | |Subtensor{:int64:} [id BB] ''
    | | | | |for{cpu,scan_fn} [id F] ''
    | | | | |Constant{-1} [id BC]
    | | | |Constant{-1} [id BD]
    | | |ScalarFromTensor [id BE] ''
    | |   |Elemwise{sub,no_inplace} [id C] ''
    | |Subtensor{:int64:} [id BF] ''
    | | |Subtensor{:int64:} [id BG] ''
    | | | |Subtensor{::int64} [id BH] ''
    | | | | |for{cpu,scan_fn} [id F] ''
    | | | | |Constant{-1} [id BI]
    | | | |Constant{-1} [id BJ]
    | | |ScalarFromTensor [id BK] ''
    | |   |Elemwise{sub,no_inplace} [id C] ''
    | |Subtensor{::int64} [id BL] ''
    | | |IncSubtensor{Inc;int64::} [id BM] ''
    | | | |Elemwise{second,no_inplace} [id BN] ''
    | | | | |for{cpu,scan_fn} [id F] ''
    | | | | |InplaceDimShuffle{x,x} [id BO] ''
    | | | |   |TensorConstant{0.0} [id BP]
    | | | |IncSubtensor{Inc;int64} [id BQ] ''
    | | | | |Elemwise{second,no_inplace} [id BR] ''
    | | | | | |Subtensor{int64::} [id BS] ''
    | | | | | | |for{cpu,scan_fn} [id F] ''
    | | | | | | |Constant{1} [id BT]
    | | | | | |InplaceDimShuffle{x,x} [id BU] ''
    | | | | |   |TensorConstant{0.0} [id BP]
    | | | | |Elemwise{second} [id BV] ''
    | | | | | |Subtensor{int64} [id BW] ''
    | | | | | | |Subtensor{int64::} [id BS] ''
    | | | | | | |Constant{-1} [id BX]
    | | | | | |InplaceDimShuffle{x} [id BY] ''
    | | | | |   |Elemwise{second,no_inplace} [id BZ] ''
    | | | | |     |Sum{acc_dtype=float64} [id CA] ''
    | | | | |     | |Subtensor{int64} [id BW] ''
    | | | | |     |TensorConstant{1.0} [id R]
    | | | | |Constant{-1} [id BX]
    | | | |Constant{1} [id BT]
    | | |Constant{-1} [id CB]
    | |Alloc [id CC] ''
    | | |TensorConstant{0.0} [id BP]
    | | |Elemwise{add,no_inplace} [id CD] ''
    | | | |Elemwise{sub,no_inplace} [id C] ''
    | | | |TensorConstant{1} [id Y]
    | | |Subtensor{int64} [id CE] ''
    | |   |Shape [id CF] ''
    | |   | |A [id P]
    | |   |Constant{0} [id CG]
    | |A [id P]
    |Constant{-1} [id CH]

    Inner graphs of the scan ops:

    for{cpu,grad_of_scan_fn}.1 [id B] ''
    >Elemwise{add,no_inplace} [id CI] ''
    > |Elemwise{mul} [id CJ] ''
    > | |<TensorType(float64, vector)> [id CK] -> [id BL]
    > | |A_copy [id CL] -> [id P]
    > |<TensorType(float64, vector)> [id CM] -> [id BL]
    >Elemwise{add,no_inplace} [id CN] ''
    > |Elemwise{mul} [id CO] ''
    > | |<TensorType(float64, vector)> [id CK] -> [id BL]
    > | |<TensorType(float64, vector)> [id CP] -> [id Z]
    > |<TensorType(float64, vector)> [id CQ] -> [id CC]

    for{cpu,scan_fn} [id F] ''
    >Elemwise{mul,no_inplace} [id CR] ''
    > |<TensorType(float64, vector)> [id CS] -> [id H]
    > |A_copy [id CT] -> [id P]

    for{cpu,scan_fn} [id F] ''
    >Elemwise{mul,no_inplace} [id CR] ''

    for{cpu,scan_fn} [id F] ''
    >Elemwise{mul,no_inplace} [id CR] ''

    for{cpu,scan_fn} [id F] ''
    >Elemwise{mul,no_inplace} [id CR] ''

    for{cpu,scan_fn} [id F] ''
    >Elemwise{mul,no_inplace} [id CR] ''(   R   RW   R   R	   RX   RY   t   gradRp   R
   R   RZ   R[   R\   R   (   RP   R4   R]   R^   R_   R`   Ra   Rb   Rc   Rd   Re   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_scan_debugprint5C  s    r%c          C` sÌ   t  j j s t d ƒ ‚ n  d „  }  t  j j d ƒ } t  j j d ƒ } t  j |  g  | g  d | d d d t ƒ\ } } t  j	 | | g | d	 | d
 t
 ƒ} t  j j | d t
 ƒt  j j | d t
 ƒd  S(   Ns   pydot not availablec         S` s   d |  S(   Ni   (    (   t   x_tm1(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   f_pow2Ð  s    t   statet   nstepsRV   t   truncate_gradientiÿÿÿÿt   go_backwardsR^   t   allow_input_downcastt   scan_graphs(   R	   R
   R   R   R   Rm   RW   RX   R   R   R   R   (   R   RŽ   RV   t   outputR^   R   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_printing_scanË  s$    			c          C` s8   t  j j ƒ  }  |  d } t  j | ƒ d k s4 t ‚ d  S(   Ni   s*   <TensorType(float64, vector)>[Constant{1}](   R	   R   R   t   ppR   (   R   t   y(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   test_subtensorä  s    
(   t   __doc__t
   __future__R    R   R   R   t   nose.plugins.skipR   Rƒ   t	   six.movesR   R	   t   theano.tensorR   t   theano.printingR   R   R!   R'   R.   R6   RB   RO   Rf   Rt   Ry   R‰   R‹   R•   R˜   (    (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/test_printing.pyt   <module>   s*   	!	
				‹	7	B	u	H	ˆ	