σ
ΰΖχXc           @` s£   d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l m	 Z	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z d e j f d     YZ d S(	   i    (   t   absolute_importt   print_functiont   divisionN(   t   Tensort
   TensorType(   t   shared(   t   SharedVariable(   t   generict   Test_SharedVariablec           B` sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C` sΗ  t  j j   d k rH t d  j t  j j k sx t t d  j   n0 t d  j t  j j k sx t t d  j   t d  j t  j j	 k s t  t t
 j d   j t  j j k sΓ t  t t
 j d d d  } | j t d d t t g k st  t t
 j j d d   } | j t d	 d t t g k sGt  t t
 j j d d
 d   } | j t d	 d t t t g k st  t g   j t k sͺt  d   } |  j t |  d  S(   Ni    i   g      @i   t   dtypet   int32t   broadcastablei   t   float64i   i   c           S` s   t  d d t d  S(   Ni   t   bad_kw(   R   t   False(    (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   badfunc!   s    (   i   i   (   t   theanot   configdefaultst   python_int_bitwidthR   t   typet   tensort   iscalart   AssertionErrort   lscalart   dscalart   npt   float32t   fscalart   zerosR   R   t   randomt   randR   t   assertRaisest	   TypeError(   t   selft   bR   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt
   test_ctors   s    30!*''*	c         C` sB   t  d d t } t  d d t } | j d  | j d  d  S(   Nt   asdft   strictiX   (   R   R   t   Truet	   set_value(   R!   t   ut   v(    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_strict_generic%   s    c      	   C` s
  t  d d d t d t g d d  d t j d d	 g  d
 t  t  d d d t d t g d d  d d d	 g d
 t  t  d d d t d t g d d  d d d g d
 t  yD t  d d d t d t g d d  d t   d
 t  d sρ t  Wn t k
 rn Xd  S(   Nt   nameR(   R   R   R	   R   t   valueg      π?g       @R%   i   i   i    (   R   R   R   R   t   asarrayt   dictR   R    (   R!   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_create_numpy_strict_false0   s0    	c      	   C` sK  t  d d d t d t g d d  d t j d d	 g  d
 t  } | j d d g  t | j    t j k sv t	  t
 | j d t  j  d k s t	  t j | j   d d g k  sΔ t	  y | j d  d sΰ t	  Wn t k
 rτ n Xt j d d d d g d d } | j | d t | j d t  | k sGt	  d  S(   NR+   R(   R   R   R	   R   R,   g      π?g       @R%   i   i   t   borrowt   adsfi    i   i   i   i   (   R   R   R   R   R-   R'   R   t	   get_valuet   ndarrayR   t   strR&   R	   t   allt
   ValueErrorR   t   _asarray(   R!   R(   t   uval(    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_use_numpy_strict_falseV   s"    	!''!c         C` s€  d   } t  t j d  d t } | j t j j k s? t  |  j	 t
 | | d  t  t j d  d t } | j t j j k s t  |  j	 t
 | | d  t  t j d  d t } | j t j j k sΧ t  |  j	 t
 | | d  t  t j d  d t } | j t j j k s#t  |  j	 t
 | | d  t  t j d  d t } | j t j j k sot  |  j	 t
 | | d  t  t j d  d t } | j t j j k s»t  |  j	 t
 | | d  t  t j d  d t } | j t j j k st  |  j	 t
 | | d  t  d d t } | j t j j k sJt  |  j	 t
 | | d  t  t j d
 d d	  } |  j	 t
 | | t j j d d   d  S(   Nc         S` s   |  j  |  d  S(   N(   R'   (   t   vart   val(    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   fs   s    i   R%   gφ(\Βu @gV-²ο@i   i   R	   R   (   i   i   (   R   R   t   int64R&   R   R   R   R   R   R   R    R
   R   t   int16t   wscalart   int8t   bscalarR   R   R   R   t   floatR   R   R   (   R!   R<   R"   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_scalar_strictr   s6    	c         C` s'  d   } t  t j d g  d t } | j t j j k sB t  |  j	 t
 | | d  t  t j d g  d t } | j t j j k s t  |  j	 t
 | | d  t  t j d g  d t } | j t j j k sΰ t  |  j	 t
 | | d  t  t j d g  d t } | j t j j k s/t  |  j	 t
 | | d  t  t j d g  d t } | j t j j k s~t  |  j	 t
 | | d  t  t j d g  d t } | j t j j k sΝt  |  j	 t
 | | d  t  t j d
 d d	  } |  j	 t
 | | t j j d d   d  S(   Nc         S` s   |  j  |  d  S(   N(   R'   (   R:   R;   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyR<      s    i   R%   gφ(\Βu @gV-²ο@i   i   R	   R   (   i   i   (   R   R   R=   R&   R   R   R   t   lvectorR   R   R    R
   t   ivectorR>   t   wvectorR@   t   bvectorR   t   dvectorR   t   fvectorR   R   R   (   R!   R<   R"   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_tensor_strict   s*    	c         C` s  d   } t  t j d  d t } | j t j j k s? t  | | d  | j	   d k sd t  t  t j
 d  d t } | j t j j k s t  | | d  | j	   d k sΏ t  t  t j d  d t } | j t j j k sυ t  | | d  | j	   d k st  t  t j d  d t } | j t j j k sPt  | | d  | j	   d k sut  t  t j d  d t } | j t j j k s«t  | | d  | j	   d k sΠt  t  t j d  d t } | j t j j k st  | | d  | j	   d k s+t  t  t j d  d t } | j t j j k sat  | | d  | j	   d k st  t  d d t } | j t j j k s³t  | | d  | j	   d k sΨt  t  t j d
 d d	  } |  j t | | t j j d d   d  S(   Nc         S` s   |  j  |  d  S(   N(   R'   (   R:   R;   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyR<   Μ   s    i   t   allow_downcastgφ(\Βu @i   gV-²ο@i   R	   R   (   i   i   (   R   R   R=   R&   R   R   R   R   R   R2   R
   R   R>   R?   R@   RA   R   R   R   R   RB   R   R   R    R   R   (   R!   R<   R"   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_scalar_floatXΒ   sF    
	c         C` s   d   } t  t j d g  d t } | j t j j k sB t  | | d g  | j	   d k sj t  t  t j
 d g  d t } | j t j j k s£ t  | | d g  | j	   d k sΛ t  t  t j d g  d t } | j t j j k st  | | d g  | j	   d k s,t  t  t j d g  d t } | j t j j k set  | | d g  | j	   d k st  t  t j d g  d t } | j t j j k sΖt  | | d g  | j	   d k sξt  t  t j d g  d t } | j t j j k s't  | | d g  | j	   d k sOt  t  t j d g d t j j d t } | j t j j k st  | | d g  | j	   d k sΌt  t  t j d
 d d	  } |  j t | | t j j d d   d  S(   Nc         S` s   |  j  |  d  S(   N(   R'   (   R:   R;   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyR<   ϋ   s    i   RK   gφ(\Βu @i   gV-²ο@R	   i   R   (   i   i   (   R   R   R=   R&   R   R   R   RD   R   R2   R
   RE   R>   RF   R@   RG   R   RH   R   RI   R-   t   configt   floatXR	   R   R   R    R   R   (   R!   R<   R"   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_tensor_floatXϊ   s@    	!	c         C` s6   |  j  t t t j j d   t t j d   d  S(   Ni   i   i   (   i   i   (   i   i   (   R   R    R   R   R   t   onesR   (   R!   (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   test_err_symbolic_variable/  s    (   t   __name__t
   __module__R#   R*   R/   R9   RC   RJ   RL   RO   RQ   (    (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyR      s   			&		'	)	8	5(   t
   __future__R    R   R   t   numpyR   t   unittestR   t   theano.tensorR   R   t   theano.compile.sharedvalueR   R   R   t   TestCaseR   (    (    (    s@   /tmp/pip-build-X4mzal/theano/theano/compile/tests/test_shared.pyt   <module>   s   