ó
àÆ÷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
 m Z m Z d Z d	 Z d
 Z d Z d Z d e e	 f d „  ƒ  YZ d e d d „ Z d S(   sÇ  
A shared variable container for true scalars - for internal use.

Why does this file exist?
-------------------------

Scalars are used to index subtensors.  Subtensor indexing is the heart of what
looks like the new scan mechanism.  This little file made it possible to catch
up to the Python interpreter in benchmarking tests.

We don't want to encourage people to use scalars (rather than 0-d tensors), but
the reason is just to keep the docs simple, not because scalars are bad.  If we
just don't register this shared variable constructor to handle any values by
default when calling theano.shared(value) then users must really go out of their
way (as scan does) to create a shared variable of this kind.

i    (   t   absolute_importt   print_functiont   divisionN(   t   integer_types(   t   SharedVariablei   (   t   Scalart   _scalar_py_operatorss   James Bergstras    (c) 2010, Universite de Montreals   3-clause BSD Licenses(   theano-dev <theano-dev@googlegroups.com>s   restructuredtext ent   ScalarSharedVariablec           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/scalar/sharedvar.pyR   !   s   c         C` s¸   t  |  t j t t t f ƒ s* t ƒ  ‚ n  y |  j } Wn# t k
 r\ t j	 |  ƒ j } n Xt
 | ƒ } t t | ƒ |  ƒ }  t d | ƒ } t d | d |  d | d | d | ƒ } | S(   s™   
    SharedVariable constructor for scalar values. Default: int64 or float64.

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

    t   dtypet   typet   valuet   namet   strictt   allow_downcast(   t
   isinstancet   numpyt   numbert   floatR   t   complext	   TypeErrorR
   t   AttributeErrort   asarrayt   strt   getattrR   R   (   R   R   R   R   R
   t   scalar_typet   rval(    (    s7   /tmp/pip-build-X4mzal/theano/theano/scalar/sharedvar.pyt   shared*   s     		(   t   __doc__t
   __future__R    R   R   R   t   sixR   t   theano.compileR   t   basicR   R   t   __authors__t   __copyright__t   __license__t   __contact__t   __docformat__R   t   Nonet   FalseR   (    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/scalar/sharedvar.pyt   <module>   s   	