ó
àÆ÷Xc           @` s¿   d  Z  d d l m Z m Z m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l Z e j d ƒ Z d	 Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e Z d S(   s9   
Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out`.

i    (   t   absolute_importt   print_functiont   division(   t   gofi   (   t   SharedVariable(   t   string_typesNs   theano.compile.ios   restructuredtext ent   SymbolicInputc           B` s>   e  Z d  Z d d d e d e e d „ Z d „  Z d „  Z RS(   s:  
    Represents a symbolic input for use with function or FunctionMaker.

    Parameters
    ----------
    variable : a Variable instance
        This will be assigned a value before running the function, not computed
        from its owner.
    name : Any type
        If autoname=True, defaults to variable.name.
        If name is a valid Python identifier, this input can be set by kwarg,
        and its value can be accessed by self.<name>.
    update : Variable instance
        Defaults to None. Value (see previous) will be replaced with this
        expression variable after each function call. If update is None, the
        update will be the default value of the input.
    mutable : bool
        Defaults to False if update is None, True if update is not None.
        True: permit the compiled function to modify the python object being
        passed as the input.
        False: do not permit the compiled function to modify the python object
        being passed as the input.
    strict : bool
        Defaults to False.
        True: means that the value you pass for this input must have exactly the
        right type.
        False: the value you pass for this input may be cast automatically to
        the proper type.
    allow_downcast : bool or None
        Defaults to None. Only applies when `strict` is False.
        True: the value you pass for this input can be silently downcasted to
        fit the right type, which may lose precision.
        False: the value will only be cast to a more general, or precise, type.
        None: Almost like False, but allows downcast of Python floats to floatX.
    autoname : bool
        Defaults to True. See the name option.
    implicit : bool
        Defaults to False. See help(In). Note that 'None' is not allowed here,
        since we are in the symbolic case.

    c	   	      C` s  | d  k	 s t ‚ | |  _ | r< | d  k r< | j |  _ n	 | |  _ |  j d  k	 r} t |  j t ƒ r} t d |  j ƒ ‚ n  | |  _ | d  k	 rÉ | j | j k sÉ t d | | j | j f ƒ ‚ qÉ n  | d  k	 rá | |  _	 n | d  k	 |  _	 | |  _
 | |  _ | |  _ d  S(   Ns    name must be a string! (got: %s)sy   Variable '%s' has type %s but an update of type %s. The type of the update should be the same as the type of the variable(   t   Nonet   AssertionErrort   variablet   namet
   isinstanceR   t	   TypeErrort   updatet   typet   mutablet   strictt   allow_downcastt   implicit(	   t   selfR	   R
   R   R   R   R   t   autonameR   (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyt   __init__=   s$    		"			c         C` s,   |  j  r d |  j |  j  f Sd |  j Sd  S(   Ns   In(%s -> %s)s   In(%s)(   R   R	   (   R   (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyt   __str__Z   s    	c         C` s
   t  |  ƒ S(   N(   t   str(   R   (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyt   __repr__`   s    N(	   t   __name__t
   __module__t   __doc__R   t   Falset   TrueR   R   R   (    (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR      s   )			t   Inc           B` s5   e  Z d  Z d d d d e d e d d e d „
 Z RS(   sc  
    Represents a symbolic input for use with function or FunctionMaker.

    Parameters
    ----------
    variable : a Variable instance
        This will be assigned a value before running the function, not computed
        from its owner.
    name : Any type
        If autoname=True, defaults to variable.name.
        If name is a valid Python identifier, this input can be set by kwarg,
        and its value can be accessed by self.<name>.
    value : Any type
        The initial/default value for this input. If update is None,
        this input acts just like an argument with a default value in
        Python. If update is not None, changes to this value will
        "stick around", whether due to an update or a user's explicit
        action.
    update : Variable instance
        Defaults to None. Value (see previous) will be replaced with this
        expression variable after each function call. If update is None, the
        update will be the default value of the input.
    mutable : bool
        Defaults to False if update is None, True if update is not None.
        True: permit the compiled function to modify the python object
        being passed as the input.
        False: do not permit the compiled function to modify the
        python object being passed as the input.
    borrow : bool
        Default : take the same value as mutable.
        True: permit the output of the compiled function to be aliased
        to the input.
        False: do not permit any output to be aliased to the input.
    strict : bool
        Defaults to False.
        True: means that the value you pass for this input must have exactly
        the right type.
        False: the value you pass for this input may be cast automatically to
        the proper type.
    allow_downcast : bool or None
        Defaults to None. Only applies when `strict` is False.
        True: the value you pass for this input can be silently downcasted to
        fit the right type, which may lose precision.
        False: the value will only be cast to a more general, or precise, type.
        None: Almost like False, but allows downcast of Python floats to floatX.
    autoname : bool
        Defaults to True. See the name option.
    implicit : bool or None
        Defaults to None.
        True: This input is implicit in the sense that the user is not allowed
        to provide a value for it. Requires 'value' to be set.
        False: The user can provide a value for this input. Be careful when
        'value' is a container, because providing an input value will
        overwrite the content of this container.
        None: Automatically choose between True or False depending on the
        situation. It will be set to False in all cases except if 'value' is a
        container (so that there is less risk of accidentally overwriting its
        content without being aware of it).

    c         C` só   | |  _  |
 d  k r! | |  _ n	 |
 |  _ | rO |  j rO t d | | ƒ ‚ n  |	 d  k r t | t j ƒ py t | t ƒ }	 n  t t	 |  ƒ j
 d | d | d | d | d | d | d | d	 |	 ƒ | |  _ |  j rï | d  k rï t d
 ƒ ‚ n  d  S(   NsÕ   Symbolic input for variable %s (name=%s) has flags mutable=True, borrow=False. This combination is incompatible since mutable=True implies that the input variable may be both aliased (borrow=True) and overwritten.R	   R
   R   R   R   R   R   R   s/   An implicit input must be given a default value(   t   sharedR   t   borrowR   R   R   t	   ContainerR   t   superR   R   t   valueR   R   (   R   R	   R
   R#   R   R   R   R   R   R   R    R   (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR   £   s.    			N(   R   R   R   R   R   R   R   (    (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR   d   s   <		t   SymbolicOutputc           B` s,   e  Z d  Z e d „ Z d „  Z d „  Z RS(   ss  
    Represents a symbolic output for use with function or FunctionMaker.

    Parameters
    ----------
    borrow : bool
        Set this to True to indicate that a reference to function's internal
        storage may be returned. A value returned for this output might be
        clobbered by running the function again, but the function might be
        faster.

    c         C` s   | |  _  | |  _ d  S(   N(   R	   R    (   R   R	   R    (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR   Û   s    	c         C` s   d |  j  |  j f S(   Ns
   Out(%s,%s)(   R	   R    (   R   (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR   ß   s    c         C` s   d |  j  |  j f S(   Ns
   Out(%s,%s)(   R	   R    (   R   (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR   â   s    (   R   R   R   R   R   R   R   (    (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyR$   Í   s   	(   R   t
   __future__R    R   R   t   theanoR   t   sharedvalueR   t   sixR   t   loggingt	   getLoggert   _loggert   __docformat__t   objectR   R   R$   t   Out(    (    (    s1   /tmp/pip-build-X4mzal/theano/theano/compile/io.pyt   <module>   s   Ri