utils – Utilities functions operating on the graph

Reference

class aesara.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

exception aesara.graph.utils.InconsistencyError[source]

This exception should be thrown by listeners to FunctionGraph when the graph’s state is invalid.

class aesara.graph.utils.MetaType(name, bases, dct)[source]
exception aesara.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 aesara.graph.utils.MissingInputError(*args, **kwargs)[source]

A symbolic input needed to compute the outputs is missing.

exception aesara.graph.utils.TestValueError[source]

Base exception class for all test value errors.

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

This Scratchpad validates attribute values.

aesara.graph.utils.add_tag_trace(thing: aesara.graph.utils.T, user_line: Optional[int] = None) aesara.graph.utils.T[source]

Add tag.trace to a node or variable.

The argument is returned after being affected (inplace).

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

Notes

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

aesara.graph.utils.simple_extract_stack(f=None, limit: Optional[int] = None, skips: Optional[Sequence[str]] = None) List[Tuple[Optional[str], int, str, Optional[str]]][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.
aesara.graph.utils.toposort(prereqs_d)[source]

Sorts prereqs_d.keys() topologically.

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