Submodules module

class, val=None)[source]

Bases: abc.ABC

An abstract class to define categories of object decorators.


This class must be subclassed for each new category.


Bases: object

A base class for types that can provide runtime values for dynamically executed (JIT-compiled) code.


Bases: object

A base class for types that can emit a unique, deterministic string representing their internal state. Subclasses may be mutable or immutable.


Subclasses must implement the method __signature_items___().


Regardless of whether an object is mutable or immutable, the returned signature must be immutable, and thus hashable.


Bases: object

A base class for types that require pickling. There are several complications that this class tries to handle:

* Packages such as SymPy have their own way of handling pickling -- though
  still based upon Python's pickle module. This may get in conflict with
  other packages, or simply with Devito itself. For example, most of Devito
  symbolic objects are created via ``def __new__(..., **kwargs)``; SymPy1.1
  pickling does not cope nicely with ``new`` and ``kwargs``, since it is
  based on the low-level copy protocol (__reduce__, __reduce_ex__) and
  simply end up ignoring ``__getnewargs_ex__``, the function responsible
  for processing __new__'s kwargs.


All sub-classes using multiple inheritance may have to explicitly set __reduce_ex__ = Pickable.__reduce_ex__ depending on the MRO. module[source]

Given items that depend on other items, a topological sort arranges items in order that no one item precedes an item it depends on.

data captures the various dependencies. It may be:

  • A dictionary whose keys are items and whose values are a set of dependent items. The dictionary may contain self-dependencies (which are ignored), and dependent items that are not also dict keys.
  • An iterable of dependences as expected by build_dependence_lists().

Readapted from: module


Bases: object

Bind together an arbitrary number of generic items. This is a mutable alternative to a namedtuple.

From:        -a-bunch-of-named/?in=user-97991

Bases: tuple

A tuple with an arbitrary number of additional attributes.


Bases: multidict._multidict.MultiDict

Specialised MultiDict object that maps a single key to a list of potential values and provides a reduction method for retrieval.

reduce(key, op=None)[source]

Returns a reduction of all candidate values for a given key.

  • key – Key for which to retrieve candidate values
  • op – Operator for reduction among candidate values. If not provided, a unique value will be returned, or a ValueError raised if no unique value exists.

Returns a dictionary with reduced/unique values for all keys.


Returns a unique value for a given key, if such a value exists, and raises a ValueError if it does not.

Parameters:key – Key for which to retrieve a unique value

Update internal mapping with standard dictionary semantics.

class, *a, **kw)[source]

Bases: collections.OrderedDict

copy() → a shallow copy of od[source]

Bases: tuple

A tuple whose elements are ordered according to a set of relations.

  • items – The elements of the tuple.
  • relations – (Optional) an iterable of binary relations between elements in items. If not provided, then items is interpreted as a totally ordered sequence. If provided, then a (partial) ordering is computed and all elements in items for which a relation is not provided are appended.
classmethod reorder(items, relations)[source] module


Bases: object

Decorator. Caches a function’s return value each time it is called. If called later with the same arguments, the cached value is returned (not reevaluated). This decorator may also be used on class methods, but it will cache at the class level; to cache at the instance level, use memoized_meth.

Adapted from:

Bases: object

Decorator. Cache the return value of a class method.

Unlike memoized_func, the return value of a given method invocation will be cached on the instance whose method was invoked. All arguments passed to a method decorated with memoize must be hashable.

If a memoized method is invoked directly on its class the result will not be cached. Instead the method will be invoked like a static method:

class Obj(object):
    def add_to(self, arg):
        return self + arg
Obj.add_to(1) # not enough arguments
Obj.add_to(1, 2) # returns 3, result is not cached

Adapted from: module


Bases: object

Context manager for changing the current working directory.

Adapted from:[source]

Create a temporary directory having a deterministic name. The directory is created within the default OS temporary directory. module[source], type=None, length=None)[source]

Force item to a tuple.

Partly extracted from:[source]

A thorough instance comparison for all integer types.[source]

Return a function f that generates integer numbers starting at 0 with stepping 1., n)[source]

Split an interable into groups of size n, plus a reminder, f)[source]

Split an iterable I into two iterables I1 and I2 of the same type as I. I1 contains all elements e in I for which f(e) returns True; I2 is the complement of I1., y)[source]

Return x rounded up to the closest multiple of y.[1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)[source][source]

Invert a dict of lists preserving the order.[source]

Flatten a hierarchy of nested lists into a plain list.[source]

Return True iff only one item is different than None, False otherwise. Note that this is not a XOR function, according to the truth table of the XOR boolean function with n > 2 inputs. Hence the name single_or., key=None)[source]

Filter elements in a list while preserving order.

Parameters:key – Optional conversion key used during equality comparison., key=None)[source]

Filter elements in a list and sort them by key. The default key is operator.attrgetter('name').[source]

Map numpy types to ctypes types.[source]

Map numpy types to MPI datatypes.[source]

Map ctypes types to C types.[source]

Create a ctypes type representing a C pointer to a custom data type name., verbose=True)[source]

Shortcut to pretty print Iteration/Expression trees., keys=None)[source]

Generator to create a parameter sweep from a dictionary of values or value lists., key=None)[source]

Rearrange an iterable into a dictionary of lists in which keys are produced by the function key. module



Decorator to validate argument types.

The decorator expects one or more arguments, which are 3-tuples of (name, type, exception), where name is the argument name in the function being decorated, type is the argument type to be validated and exception is the exception type to be raised if validation fails.

Readapted from:
check_arg(arg, argtype, exception)[source] module


Bases: object

A generic visitor.

To define handlers, subclasses should define visit_Foo methods for each class Foo they want to handle. If a specific method for a class Foo is not found, the MRO of the class is walked in order until a matching method is found.

The method signature is:

The handler is responsible for visiting the children (if any) of the node o. *args and **kwargs may be used to pass information up and down the call stack. You can also pass named keyword arguments, e.g.:

default_args = {}
classmethod default_retval()[source]

A method that returns an object to use to populate return values.

If your visitor combines values in a tree-walk, it may be useful to provide a object to combine the results into. default_retval() may be defined by the visitor to be called to provide an empty object of appropriate type.


Look up a handler method for a visitee.

Parameters:instance – The instance to look up a method for.
visit(o, *args, **kwargs)[source]

Apply this Visitor to an object.

  • o – The Node to visit.
  • args – Optional arguments to pass to the visit methods.
  • kwargs – Optional keyword arguments to pass to the visit methods.
visit_object(o, **kwargs)[source]

Module contents