ó
àÆ÷Xc           @` sú   d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l m Z d  d l Z	 d  d l m
 Z
 m Z d  d l m Z m Z d „  Z d e e f d „  ƒ  YZ e d e d e d d	 d
 „ ƒ Z d e e f d „  ƒ  YZ e d e d e d	 d „ ƒ Z d S(   i    (   t   absolute_importt   print_functiont   divisionN(   t   integer_types(   t
   TensorTypet   _tensor_py_operators(   t   shared_constructort   SharedVariablec         C` s
   t  |  ƒ S(   s¦   
    This function is only here to keep some pickles loading
    after a failed fix done in August 2011.
    It can be removed after sufficient time has passed.

    (   t   tensor_constructor(   t   val(    (    s7   /tmp/pip-build-X4mzal/theano/theano/tensor/sharedvar.pyt   load_shared_variable   s    t   TensorSharedVariablec           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/tensor/sharedvar.pyR      s   t   cpuc         C` s¨   | d k r t  d ƒ ‚ n  t |  t j ƒ s9 t  ƒ  ‚ n  | d
 k r^ t f t |  j ƒ } n  t |  j	 d | ƒ} t
 d | d t j |  d | ƒd | d | d	 | ƒ S(   s^  
    SharedVariable Constructor for TensorType.

    Notes
    -----
    Regarding the inference of the broadcastable pattern...
    The default is to assume that the value might be resized in any
    dimension, so the default broadcastable is ``(False,)*len(value.shape)``.
    The optional `broadcastable` argument will override this default.

    R   s   not for cput   broadcastablet   typet   valuet   copyt   namet   strictt   allow_downcastN(   t	   TypeErrort
   isinstancet   numpyt   ndarrayt   Nonet   Falset   lent   shapeR   t   dtypeR   t   array(   R   R   R   R   t   borrowR   t   targetR   (    (    s7   /tmp/pip-build-X4mzal/theano/theano/tensor/sharedvar.pyR      s    t   ScalarSharedVariablec           B` s   e  Z RS(    (   R   R   (    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/tensor/sharedvar.pyR"   C   s   c   	      C` s  | d k r t  d ƒ ‚ n  t |  t j t t t f ƒ sE t  ƒ  ‚ n  y |  j } Wn# t k
 rw t j	 |  ƒ j } n Xt
 | ƒ } t j |  d | ƒ}  t d t
 |  j ƒ d g  ƒ } y> t d | d t j |  d t ƒd | d	 | d
 | ƒ } | SWn t k
 rt j ƒ  ‚  n Xd S(   sY  
    SharedVariable constructor for scalar values. Default: int64 or float64.

    Notes
    -----
    We implement this using 0-d tensors for now.

    We ignore the borrow parameter as we convert ``value`` to an
    ndarray (this is a new object). This respects the semantic of
    borrow, as it is a hint to Theano that we can reuse it.

    R   s   not for cpuR   R   R   R   R   R   R   R   N(   R   R   R   t   numbert   floatR   t   complexR   t	   Exceptiont   asarrayt   strt   theanot   _asarrayR   R"   R   t   Truet	   tracebackt	   print_exc(	   R   R   R   R   R    R!   R   t   tensor_typet   rval(    (    s7   /tmp/pip-build-X4mzal/theano/theano/tensor/sharedvar.pyt   scalar_constructorG   s*    	
(   t
   __future__R    R   R   R,   R   t   sixR   t   theano.tensor.basicR)   R   R   t   theano.compileR   R   R
   R   R   R   R   R"   R0   (    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/tensor/sharedvar.pyt   <module>   s   		&	