mrv.dge

Epydoc: mrv.dge

Contains a simple but yet powerful dependency graph engine allowing computations to be organized more efficiently.

Functions

mrv.dge.iterShells(rootPlugShell, stopAt=<function <lambda> at 0x2eba938>, prune=<function <lambda> at 0x2ebab18>, direction='up', visit_once=False, branch_first=False)

Iterator starting at rootPlugShell going “up”stream ( input ) or “down”stream ( output ) breadth first over plugs, applying filter functions as defined.

Parameters:
  • rootPlugShell – shell at which to start the traversal. The root plug will be returned as well
  • stopAt – if function returns true for given PlugShell, iteration will not proceed at that point ( possibly continuing at other spots ). Function will always be called, even if the shell would be pruned as well. The shell serving as stop marker will not be returned
  • prune – if function returns true for given PlugShell, the shell will not be returned but iteration continues.
  • direction – traversal direction “up” upstream, in direction of inputs of plugs “down” downstream, in direction of outputs of plugs
  • visit_once – if True, plugs will only be returned once, even though they are
  • branch_first – if True, individual branches will be travelled first ( thuse the node will be left quickly following the datastream ). If False, the plugs on the ndoe will be returned first before proceeding to the next node encountered several times as several noodes are connected to them in some way.

Classes

Epydoc: mrv.dge.Attribute

class mrv.dge.Attribute(typeClass, flags, default=None)

Bases: object

Simple class defining the type of a plug and several flags that affect it. Additionally it can determine how well suited another attribute is

Flags:
exact_type: if True, derived classes of our typecls are not considered to be a valid type. i.e: basestring could be stored in a str attr if exact type is false - its less than we need, but still something. Putting a str into a basestring attribute will always work though, as it would be more than we need readonly: if True, the attribute’s plug cannot be written to. Read-only attributes can be used as storage that the user can read, but not write. You can write read-only plugs by directly setting its cache - this of course - is only for the node itself, but will never be done by the framework
computable:

Nodes are automatically computable if they are affected by another plug. If this is not the case, they are marked input only and are not computed. If this flag is true, even unaffeted plugs are computable. Plugs that affect something are automatically input plugs and will not be computed. If the plug does not affect anything and this flag is False, they are seen as input plugs anyway.

The system does not allow plugs to be input and output plugs at the same time, thus your compute cannot be triggered by your own compute

cls: if True, the plug requires classes to be set ( instances of ‘type’ ) , but no instances of these classes uncached: if False, computed values may be cached, otherwise they will always be recomputed. unconnectable: if True, the node cannot be the destination of a connection check_passing_values: check each value as it flows through a connection - usually compatability is only checked on connection and once values are set, but not if they flow through an existing connection

Default Values:
Although default values can be simple primitives are classes, a callable is specifically supported. It allows you to get a callback whenever a default value is required. The same result could be achieved by connected the plug in question, but dynamic defaults are a quick way to achive that. Your returned value will be type-checked against the required type if check_passing_values is set.
affinity(otherattr)

Compute affinity for otherattr.

Returns:rating from 0 to 255 defining how good the attribtues match each other in general - how good can we store values of otherattr ? Thus this comparison is directed.
Note:for checking connections, use connectionAffinity
compatabilityRate(value)

Compute value’s compatability rate

Returns:value between 0 and 255, 0 means no compatability, 255 a perfect match. if larger than 0, the plug can hold the value ( assumed the flags are set correctly ).
connectionAffinity(destinationattr)

Compute connection affinity for given destination attribute

Returns:rating from 0 to 255 defining the quality of the connection to otherplug. an affinity of 0 mean connection is not possible, 255 mean the connection is perfectly suited. The connection is a directed one from self -> otherplug
default()
Returns:default value stored for this attribute, or raise
Note:handles dynamic defaults, so you should not directly access the default member variable
Raises MissingDefaultValueError:
 if attribute does not have a default value
Raises TypeError:
 if value returned by dynamic attribute has incorrect type

Epydoc: mrv.dge.Graph

class mrv.dge.Graph(**kwargs)

Bases: networkx.classes.digraph.DiGraph, mrv.interface.iDuplicatable

Holds the nodes and their connections

Nodes are kept in a separate list whereas the plug connections are kept in the underlying DiGraph

addNode(node)
Add a new node instance to the graph :note: node membership is exclusive, thus node instances can only be in one graph at a time :return: self, for chained calls
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
add_cycle(nlist, **attr)
add_edge(u, v, attr_dict=None, **attr)
add_edges_from(ebunch, attr_dict=None, **attr)
add_node(n, attr_dict=None, **attr)
add_nodes_from(nodes, **attr)
add_path(nlist, **attr)
add_star(nlist, **attr)
add_weighted_edges_from(ebunch, **attr)
adjacency_iter()
adjacency_list()
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

clear()
clearCache()
Clear the cache of all nodes in the graph - this forces the graph to reevaluate on the next request
connect(sourceshell, destinationshell, force=False)

Connect this plug to destinationshell such that destinationshell is an input plug for our output

Parameters:
  • sourceshell – PlugShell being source of the connection
  • destinationshell – PlugShell being destination of the connection
  • force – if False, existing connections to destinationshell will not be broken, but an exception is raised if True, existing connection may be broken
Returns:

self on success, allows chained connections

Raises PlugAlreadyConnected:
 

if destinationshell is connected and force is False

Raises PlugIncompatible:
 

if destinationshell does not appear to be compatible to this one

copy()
copyFrom(other)
Duplicate all data from other graph into this one, create a duplicate of the nodes as well
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance()
Create a copy of self and return it
degree(nbunch=None, with_labels=False, weighted=False)
degree_iter(nbunch=None, weighted=False)
disconnect(sourceshell, destinationshell)
Remove the connection between sourceshell to destinationshell if they are connected :note: does not raise if no connection is present
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
edges(nbunch=None, data=False)
edges_iter(nbunch=None, data=False)
fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
get_edge_data(u, v, default=None)
hasNode(node)
Returns:True if the node is in this graph, false otherwise
has_edge(u, v)
has_node(n)
has_predecessor(u, v)
has_successor(u, v)
in_degree(nbunch=None, with_labels=False, weighted=False)
in_degree_iter(nbunch=None, weighted=False)
in_edges(nbunch=None, data=False)
in_edges_iter(nbunch=None, data=False)
input(plugshell)
Returns:the connected input plug of plugshell or None if there is no such connection
Note:input plugs have on plug at most, output plugs can have more than one connected plug
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
is_directed()
is_multigraph()
iterConnectedNodes(predicate=<function <lambda> at 0x2ed0aa0>)
Returns:generator returning all nodes that are connected in this graph, in no particular order. For an ordered itereration, use iterShells.
Parameter:predicate – if True for node, it will be returned
iterNodes(predicate=<function <lambda> at 0x2ed09b0>)
Returns:generator returning all nodes in this graph
Parameter:predicate – if True for node, it will be returned
Note:there is no particular order
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
nbunch_iter(nbunch=None)
neighbors(n)
neighbors_iter(n)
nodeByID(nodeID)
Returns:instance of a node according to the given node id
Raises NameError:
 if no such node exists in graph
nodes()
Returns:immutable copy of the nodes used in the graph
nodes_iter(data=False)
nodes_with_selfloops()
numNodes()
Returns:number of nodes in the graph
number_of_edges(u=None, v=None)
number_of_nodes()
number_of_selfloops()
order()
out_degree(nbunch=None, with_labels=False, weighted=False)
out_degree_iter(nbunch=None, weighted=False)
out_edges(nbunch=None, data=False)
out_edges_iter(nbunch=None, data=False)
outputs(plugshell, predicate=<function <lambda> at 0x2ed0e60>)
Returns:a list of plugs being the destination of the connection to plugshell
Parameter:predicate – plug will only be returned if predicate is true for it - shells will be passed in
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
predecessors(n)
predecessors_iter(n)
removeNode(node)
Remove the given node from the graph ( if it exists in it )
remove_edge(u, v)
remove_edges_from(ebunch)
remove_node(n)
remove_nodes_from(nbunch)
reverse(copy=True)
root()
Returns:the root of the DAG - it has no further parents
selfloop_edges(data=False)
size(weighted=False)
subgraph(nbunch, copy=True)
successors(n)
successors_iter(n)
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
to_directed()
to_undirected()
writeDot(fileOrPath)
Write the connections in self to the given file object or path :todo: remove if no longer needed

Epydoc: mrv.dge.NodeBase

class mrv.dge.NodeBase(*args, **kwargs)

Bases: mrv.interface.iDuplicatable

Base class that provides support for plugs to the superclass. It will create some simple tracking attriubtes required for the plug system to work

Nodes can compute values of their plugs if these do not have a cache.

Nodes are identified by an ID - the default graph implementation though will be okay with just having instances. It is also being used for string representations of this node

classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

clearCache()
Clear the cache of all plugs on this node - this basically forces it to recompute the next time an output plug is being queried
compute(plug, mode)

Called whenever a plug needs computation as the value its value is not cached or marked dirty ( as one of the inputs changed )

Parameters:
  • plug – the static plug instance that requested which requested the computation. It is the instance you defined on the class
  • mode – the mode of operation. Its completely up to the superclasses how that attribute is going to be used
Note:

to be implemented by superclass

connections(inpt, output)
Returns:

Tuples of input shells defining a connection of the given type from tuple( InputNodeOuptutShell, OurNodeInputShell ) for input connections and tuple( OurNodeOuptutShell, OutputNodeInputShell )

Parameters:
  • inpt – include input connections to this node
  • output – include output connections ( from this node to others )
copyFrom(other, add_to_graph=True)

Just take the graph from other, but do not ( never ) duplicate it

Parameter:add_to_graph – if true, the new node instance will be added to the graph of
Note:default implementation does not copy plug caches ( which are stored in the node dict - this is because a reevaluate is usually required on the duplicated node
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create a copy of self and return it

Note:override by subclass - the __init__ methods shuld do the rest
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
classmethod filterCompatiblePlugs(plugs, attrOrValue, raise_on_ambiguity=False, attr_affinity=False, attr_as_source=True)
Returns:

sorted list of (rate,plug) tuples suitable to deal with the given attribute. Thus they could connect to it as well as get their value set. Most suitable plug comes first. Incompatible plugs will be pruned.

Parameters:
  • attrOrValue – either an attribute or the value you would like to set to the attr at the plug in question.
  • raise_on_ambiguity – if True, the method raises if a plug has the same rating as another plug already on the output list, thus it’s not clear anymore which plug should handle a request
  • attr_affinity – if True, it will not check connection affinity, but attribute affinity only. It checks how compatible the attributes of the plugs are, disregarding whether they can be connected or not Only valid if attrOrValue is an attribute
  • attr_as_source – if True, attrOrValue will be treated as the source of a connection or each plug would need to take its values. if False, attrOrValue is the destination of a connection and it needs to take values of the given plugs or they would connect to it. Only used if attrOrValue is an attribute.
Raises TypeError:
 

if ambiguous input was found

fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
id()
Returns:ID of this instance
inputPlugs(**kwargs)
Returns:list of plugs suitable as input
Note:convenience method
classmethod inputPlugsStatic(**kwargs)
Returns:list of static plugs suitable as input
Note:convenience method
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
outputPlugs(**kwargs)
Returns:list of plugs suitable to deliver output
Note:convenience method
classmethod outputPlugsStatic(**kwargs)
Returns:list of static plugs suitable to deliver output
Note:convenience method
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
plugs(predicate=<function <lambda> at 0x2ed1668>)
Returns:list of dynamic plugs as defined on this node - they are usually retrieved on class level, but may be overridden on instance level
Parameter:predicate – return static plug only if predicate is true
classmethod plugsStatic(predicate=<function <lambda> at 0x2ed1578>)
Returns:list of static plugs as defined on this node - they are class members
Parameter:predicate – return static plug only if predicate is true
Note:Use this method only if you do not have an instance - there are nodes that actually have no static plug information, but will dynamically generate them. For this to work, they need an instance - thus the plugs method is an instance method and is meant to be the most commonly used one.
root()
Returns:the root of the DAG - it has no further parents
setID(newID)
Set id of this node to newiD :return: previously assigned id
shellcls
alias of _PlugShell
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work
toShell(plug)
Returns:a plugshell as suitable to for this class
toShells(plugs)
Returns:list of shells made from plugs and our node

Epydoc: mrv.dge._NodeBaseCheckMeta

class mrv.dge._NodeBaseCheckMeta

Bases: type

Class checking the consistency of the nodebase class before it is being created

mro
mro() -> list return a type’s method resolution order

Epydoc: mrv.dge._PlugShell

class mrv.dge._PlugShell

Bases: tuple

Handles per-node-instance plug connection setup and storage. As plugs are descriptors and thus an instance of the class, per-node-instance information needs special treatment. This class is being returned whenever the descriptors get and set methods are called, it contains information about the node and the plug being involved, allowing to track connection info directly using the node dict

This allows plugs to be connected, and information to flow through the dependency graph. Plugs never act alone since they always belong to a parent node that will be asked for value computations if the value is not yet cached. :note: Do not instantiate this class youself, it must be created by the node as different node types can use different versions of this shell

cache()
Returns:the cached value or raise
Raises ValueError:
 
clearCache(clear_affected=False, cleared_shells_set=None)
Empty the cache of our plug :param clear_affected: if True, the caches of our affected plugs ( connections or affects relations ) will also be cleared This operation is recursive, and needs to be as different shells on different nodes might do things differently. :param cleared_shells_set: if set, it can be used to track which plugs have already been dirtied to prevent recursive loops Propagation will happen even if we do not have a cache to clear ourselves
compatabilityRate(value)

Compute compatability rate for teh given value

Returns:value between 0 and 255, 0 means no compatability, 255 a perfect match if larger than 0, the plug can hold the value ( assumed the flags are set correctly )
connect(otherplugshell, **kwargs)

Connect this plug to otherplugshell such that otherplugshell is an input plug for our output

Parameter:kwargs – everything supported by Graph.connect
Returns:self on success, allows chained connections
Raises PlugAlreadyConnected:
 if otherplugshell is connected and force is False
Raises PlugIncompatible:
 if otherplugshell does not appear to be compatible to this one
connections(inpt, output, predicate=<function <lambda> at 0x2ed0050>)
Returns:get all input and or output connections from this shell or to this shell as edges ( sourceshell, destinationshell )
Parameter:predicate – return true for each destination shell that you can except in the returned edge or the sourceshell where your shell is the destination.
Note:Use this method to get edges read for connection/disconnection
count
T.count(value) -> integer – return number of occurrences of value
disconnect(otherplugshell)
Remove the connection to otherplugshell if we are connected to it. :note: does not raise if no connection is present
get(mode=None)
Returns:value of the plug
Parameter:mode – optional arbitary value specifying the mode of the get attempt
hasCache()
Returns:True if currently store a cached value
index
T.index(value, [start, [stop]]) -> integer – return first index of value. Raises ValueError if the value is not present.
input(predicate=<function <lambda> at 0x2ecfde8>)
Returns:the connected input plug or None if there is no such connection
Parameter:predicate – plug will only be returned if predicate is true for it
Note:input plugs have on plug at most, output plugs can have more than one connected plug
isConnected()
Returns:True, if the shell is connected as source or as destination of a connection
iterShells(**kwargs)
Iterate plugs and their connections starting at this plug :return: generator for plug shells :note: supports all options of iterShells, this method allows syntax like: node.outAttribute.iterShells( )
outputs(predicate=<function <lambda> at 0x2ecfed8>)
Returns:a list of plugs being the destination of the connection
Parameter:predicate – plug will only be returned if predicate is true for it - shells will be passed in
set(value, ignore_connection=False)
Set the given value to be used in our plug :param ignore_connection: if True, the plug can be destination of a connection and will still get its value set - usually it would be overwritten by the value form the connection. The set value will be cleared if something upstream in it’s connection chain changes. :raise AssertionError: the respective attribute must be cached, otherwise the value will be lost
setCache(value)
Set the given value to be stored in our cache :raise: TypeError if the value is not compatible to our defined type

Epydoc: mrv.dge

class mrv.dge.deque

Bases: object

deque(iterable[, maxlen]) –> deque object

Build an ordered collection accessible from endpoints only.

append
Add an element to the right side of the deque.
appendleft
Add an element to the left side of the deque.
clear
Remove all elements from the deque.
extend
Extend the right side of the deque with elements from the iterable
extendleft
Extend the left side of the deque with elements from the iterable
pop
Remove and return the rightmost element.
popleft
Remove and return the leftmost element.
remove
D.remove(value) – remove first occurrence of value.
rotate
Rotate the deque n steps to the right (default n=1). If n is negative, rotates left.

Epydoc: mrv.dge

class mrv.dge.iDuplicatable

Bases: mrv.interface.Interface

Simple interface allowing any class to be properly duplicated

Note:to implement this interface, implement createInstance and copyFrom in your class
classmethod addSep(item, sep)
Returns:

item with separator added to it ( just once )

Note:

operates best on strings

Parameters:
  • item – item to add separator to
  • sep – the separator
basename()
Returns:basename of this path, ‘/hello/world’ -> ‘world’
children(predicate=<function <lambda> at 0x7f41dd7c2ed8>)
Returns:list of intermediate children of path, [ child1 , child2 ]
Parameter:predicate – return True to include x in result
Note:the child objects returned are supposed to be valid paths, not just relative paths
childrenDeep(order=1, predicate=<function <lambda> at 0x7f41dd7c5050>)
Returns:

list of all children of path, [ child1 , child2 ]

Parameters:
  • order – order enumeration
  • predicate – returns true if x may be returned
Note:

the child objects returned are supposed to be valid paths, not just relative paths

copyFrom(other, *args, **kwargs)

Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note:you must support args and kwargs if one of your iDuplicate bases does
copyTo(instance, *args, **kwargs)

Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance

Returns:altered instance
Note:instance will be altered during the process
copyToOther(instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo
createInstance(*args, **kwargs)

Create and Initialize an instance of self.__class__( ... ) based on your own data

Returns:new instance of self
Note:using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
Note:you must support args and kwargs if one of your iDuplicate bases does
duplicate(*args, **kwargs)

Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class

Parameters:
  • args – passed to copyFrom and createInstance method to give additional directions
  • kwargs – see param args
fullChildName(childname)
Add the given name to the string version of our instance :return: string with childname added like name _sep childname
isPartOf(other)
Returns:True if self is a part of other, and thus can be found in other
Note:operates on strings only
isRoot()
Returns:True if this path is the root of the DAG
isRootOf(other)
Returns:True other starts with self
Note:operates on strings
Note:we assume other has the same type as self, thus the same separator
iterParents(predicate=<function <lambda> at 0x7f41dd7c5230>)
Returns:generator retrieving all parents up to the root
Parameter:predicate – returns True for all x that you want to be returned
parent()
Returns:parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root
parentDeep()
Returns:all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ]
root()
Returns:the root of the DAG - it has no further parents
supports(interface_type)
Returns:True if this instance supports the interface of the given type
Parameter:interface_type – Type of the interface you require this instance to support
Note:Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work

Epydoc: mrv.dge.iPlug

class mrv.dge.iPlug

Bases: object

Defines an interface allowing to compare compatabilies according to types.

Plugs can either be input plugs or output plugs - output plugs affect no other plug on a node, but are affected by 0 or more plugs .

By convention, a plug has a name - that name must also be the name of the member attribute that stores the plag. Plugs, possibly different instances of it, need to be re-retrieved on freshly duplicated nodes to allow graph duplication to be done properly

Note:if your plug class supports the setName method, a metaclass will adjust the name of your plug to match the name it has in the parent class
affected()
Returns:tuple containing affected plugs ( plugs that are affected by our value )
affectedBy()
Returns:tuple containing plugs that affect us ( plugs affecting our value )
affects(otherplug)
Set an affects relation ship between this plug and otherplug, saying that this plug affects otherplug.
name()
Returns:name of the plug ( the name that identifies it on the node
providesInput()
Returns:True if this is an input plug that will never cause computations
providesOutput()
Returns:True if this is an output plug that can trigger computations

Epydoc: mrv.dge.plug

class mrv.dge.plug(attribute)

Bases: mrv.dge.iPlug

Defines an interface allowing to compare compatabilies according to types.

Plugs are implemented as descriptors, thus they will be defined on node class level, and all static information will remain static

As descriptors, they are defined statically on the class, and some additional information such as connectivity, is stored on the respective class instance. These special methods are handled using NodeBase class

Plugs are implemented as descriptors as all type information can be kept per class, whereas only connection information changes per node instance.

Plugs can either be input plugs or output plugs - output plugs affect no other plug on a node, but are affected by 0 or more plugs

Note:class is lowercase as it is used as descriptor ( acting more like a function )
affected()
Returns:tuple containing affected plugs ( plugs that are affected by our value )
affectedBy()
Returns:tuple containing plugs that affect us ( plugs affecting our value )
affects(otherplug)
Set an affects relation ship between this plug and otherplug, saying that this plug affects otherplug.
name()
Returns:name of plug
providesInput()
Returns:True if this is an input plug that will never cause computations
providesOutput()
Returns:True if this is an output plug that can trigger computations
setName(name)
Set the name of this plug - can be set only once

Exceptions

Epydoc: mrv.dge.AccessError

class mrv.dge.AccessError

Bases: exceptions.Exception

Base class for all errors indicating invalid access

args
message

Epydoc: mrv.dge.ComputeError

class mrv.dge.ComputeError

Bases: exceptions.Exception

Thrown if the computation done by a plug failed by an unknown exception It will be passed on in the exception

args
message

Epydoc: mrv.dge.ComputeFailed

class mrv.dge.ComputeFailed

Bases: mrv.dge.ComputeError

Raised by the derived class computing a value if the computational goal cannot be achieved ( anymore )

args
message

Epydoc: mrv.dge.ConnectionError

class mrv.dge.ConnectionError

Bases: exceptions.Exception

Exception base for all plug related errors

args
message

Epydoc: mrv.dge.MissingDefaultValueError

class mrv.dge.MissingDefaultValueError

Bases: mrv.dge.AccessError

Thrown if a default value is missing for input attributes that are not connected

args
message

Epydoc: mrv.dge.NotReadableError

class mrv.dge.NotReadableError

Bases: mrv.dge.AccessError

Thrown if a non-readable attribute is being read

args
message

Epydoc: mrv.dge.NotWritableError

class mrv.dge.NotWritableError

Bases: mrv.dge.AccessError

Thrown if a non-writable plug is being written to

args
message

Epydoc: mrv.dge.PlugAlreadyConnected

class mrv.dge.PlugAlreadyConnected

Bases: mrv.dge.ConnectionError

Thrown if one tries to connect a plug to otherplug when otherplug is already connected

args
message

Epydoc: mrv.dge.PlugIncompatible

class mrv.dge.PlugIncompatible

Bases: mrv.dge.ConnectionError, exceptions.TypeError

Thrown whenever plugs are not compatible with each other during connection

args
message

Epydoc: mrv.dge.PlugUnhandled

class mrv.dge.PlugUnhandled

Bases: mrv.dge.ComputeError

Raised if a plug was not handled by the node’s compute method

args
message

Table Of Contents

Previous topic

mrv.interface

Next topic

mrv.thread

This Page