utils – Utilities functions operating on the graph


class theano.graph.utils.AssocList[source]

An associative list.

This class is like a dict that accepts unhashable keys by using an assoc list for internal use only

class theano.graph.utils.MetaType(name, bases, dct)[source]
exception theano.graph.utils.MethodNotDefined[source]

To be raised by functions defined as part of an interface.

When the user sees such an error, it is because an important interface function has been left out of an implementation class.

exception theano.graph.utils.TestValueError[source]

Base exception class for all test value errors.

class theano.graph.utils.ValidatingScratchpad(attr, attr_filter)[source]

This Scratchpad validates attribute values.

theano.graph.utils.add_tag_trace(thing, user_line=None)[source]

Add tag.trace to a node or variable.

The argument is returned after being affected (inplace).

  • thing – The object where we add .tag.trace.
  • user_line – The max number of user line to keep.


We also use config.traceback__limit for the maximum number of stack level we look.

theano.graph.utils.simple_extract_stack(f=None, limit=None, skips=None)[source]

This is traceback.extract_stack from python 2.7 with this change:

  • Comment the update of the cache.
  • Skip internal stack trace level.

The update of the cache call os.stat to verify is the cache is up to date. This take too much time on cluster.

limit - The number of stack level we want to return. If None, mean all what we can.

skips - partial path of stack level we don’t want to keep and count.
When we find one level that isn’t skipped, we stop skipping.

Sorts prereqs_d.keys() topologically.

prereqs_d[x] contains all the elements that must come before x in the ordering.