| |
- exceptions.Exception(exceptions.BaseException)
-
- ValidityError
- Method
-
- AddMethod
- AssignMethod
- SetMethod
- SubMethod
- MethodGraph
class AddMethod(Method) |
| |
Methods defined here:
- __init__(self, a, b, c)
- new method c := a + b
- __str__(self)
- execute(self, inmap)
Methods inherited from Method:
- inputs(self)
- return a list of input variables
If an attribute '_inputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
- outputs(self)
- return a list of output variables
If an attribute '_outputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
|
class AssignMethod(Method) |
| |
Methods defined here:
- __init__(self, a, b)
- new method a := b
keyword arguments:
a - variable name
b - variable name
- __str__(self)
- execute(self, inmap)
Methods inherited from Method:
- inputs(self)
- return a list of input variables
If an attribute '_inputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
- outputs(self)
- return a list of output variables
If an attribute '_outputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
|
class Method |
|
Abstract method
A Method is an object that defines input variables, output variables
and an execute method. This class should be considered abstract.
Instances (of subclasses of) Method must be non-mutable, hashable objects. |
|
Methods defined here:
- execute(self, inmap)
- Execute method.
Returns a mapping (dictionary) of output variables to values,
given an input map, mapping input variables to values (dictionary)
The previous value of the output variable should also be in inmap.
If the method cannot be executed, it should return an empty map.
- inputs(self)
- return a list of input variables
If an attribute '_inputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
- outputs(self)
- return a list of output variables
If an attribute '_outputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
|
class MethodGraph |
|
Implementation of a method graph
A method graph is represented by
a directed bi-partite graph: nodes are either varables or methods.
Edges run from input variables to methods and from methods to ouput
variables.
A method graph may not contain cycles. Every variable must be
determined by at most one constraint.
Methods must be instances of (subclasses of) class Method.
Variables are basically just names, and may be any
non-mutable, hashable object, e.g. strings.
Values associated with variables may be of any type.
If no value is explicitly associated with a variable, it defaults to None. |
|
Methods defined here:
- __init__(self)
- __str__(self)
- add_method(self, met, prop=True)
- Add a method.
Iff prop is true then this change and any pending
changes will be propagated.
- add_variable(self, varname, value=None)
- Add a variable, optionally with a value
- clear(self)
- clear methodgraph by removing all variables
- execute(self, met)
- Execute a method and proagate changes. Method must be in Methodgraph
- get(self, varname)
- get the value of a variable
- methods(self)
- return a list of methods
- propagate(self)
- Propagate any pending changes.
Changes are propagated until no changes are left or until
no more changes can be propagated. This method is called
from set() and add_method() by default. However, if the
user so chooses, the methods will not call propagate, and
the user should call this fucntion at a convenient time.
- rem_method(self, met)
- Remove a method
- rem_variable(self, varname)
- Remove a variable and all methods on that variable
- set(self, varname, value, prop=True)
- Set the value of a variable.
Iff prop is true then this change and any pending
changes will be propagated.
- variables(self)
- return a list of variables
|
class SetMethod(Method) |
| |
Methods defined here:
- __init__(self, var, value)
- new method var := value
keyword arguments:
var - variable name
value - any object to be associated with var
- __str__(self)
- execute(self, inmap)
Methods inherited from Method:
- inputs(self)
- return a list of input variables
If an attribute '_inputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
- outputs(self)
- return a list of output variables
If an attribute '_outputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
|
class SubMethod(Method) |
| |
Methods defined here:
- __init__(self, a, b, c)
- new method c := a - b
- __str__(self)
- execute(self, inmap)
Methods inherited from Method:
- inputs(self)
- return a list of input variables
If an attribute '_inputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
- outputs(self)
- return a list of output variables
If an attribute '_outputs' has been defined, a new list
with the contents of that attribute will be returned.
Subclasses may choose to initialise this variable or to
override this function.
|
|