345 lines
22 KiB
HTML
345 lines
22 KiB
HTML
|
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: module geosolver.method</title>
|
|
</head><body bgcolor="#f0f0f8">
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
<tr bgcolor="#7799ee">
|
|
<td valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="geosolver.html"><font color="#ffffff">geosolver</font></a>.method</strong></big></big></font></td
|
|
><td align=right valign=bottom
|
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/rick/Programming/Python/GeoSolver/geosolver/method.py">/home/rick/Programming/Python/GeoSolver/geosolver/method.py</a></font></td></tr></table>
|
|
<p><tt>Module for method graphs <br>
|
|
Copyright Rick van der Meiden, 2003, 2004<br>
|
|
Created: 1 Nov 2003.<br>
|
|
<br>
|
|
A method graph contains variables and methods. Methods are objects that<br>
|
|
specify input and output variables and an 'execute' method. Whenever the<br>
|
|
value of a variable is changed, one or more methods are executed to update<br>
|
|
the value of 'upstream' variables. <br>
|
|
<br>
|
|
Changes:<br>
|
|
23 Nov 2004 - added Error classes, updated naming and doc conventions (<a href="http://www.python.org/peps/pep-0008.html">PEP 8</a>, 257)</tt></p>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ee77aa">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl>
|
|
<dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>(<a href="exceptions.html#BaseException">exceptions.BaseException</a>)
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="geosolver.method.html#ValidityError">ValidityError</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="geosolver.method.html#Method">Method</a>
|
|
</font></dt><dd>
|
|
<dl>
|
|
<dt><font face="helvetica, arial"><a href="geosolver.method.html#AddMethod">AddMethod</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="geosolver.method.html#AssignMethod">AssignMethod</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="geosolver.method.html#SetMethod">SetMethod</a>
|
|
</font></dt><dt><font face="helvetica, arial"><a href="geosolver.method.html#SubMethod">SubMethod</a>
|
|
</font></dt></dl>
|
|
</dd>
|
|
<dt><font face="helvetica, arial"><a href="geosolver.method.html#MethodGraph">MethodGraph</a>
|
|
</font></dt></dl>
|
|
<p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="AddMethod">class <strong>AddMethod</strong></a>(<a href="geosolver.method.html#Method">Method</a>)</font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="AddMethod-__init__"><strong>__init__</strong></a>(self, a, b, c)</dt><dd><tt>new method c := a + b</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AddMethod-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="AddMethod-execute"><strong>execute</strong></a>(self, inmap)</dt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="geosolver.method.html#Method">Method</a>:<br>
|
|
<dl><dt><a name="AddMethod-inputs"><strong>inputs</strong></a>(self)</dt><dd><tt>return a list of input variables<br>
|
|
<br>
|
|
If an attribute '_inputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AddMethod-outputs"><strong>outputs</strong></a>(self)</dt><dd><tt>return a list of output variables<br>
|
|
<br>
|
|
If an attribute '_outputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="AssignMethod">class <strong>AssignMethod</strong></a>(<a href="geosolver.method.html#Method">Method</a>)</font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="AssignMethod-__init__"><strong>__init__</strong></a>(self, a, b)</dt><dd><tt>new method a := b<br>
|
|
<br>
|
|
keyword arguments:<br>
|
|
a - variable name<br>
|
|
b - variable name</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AssignMethod-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="AssignMethod-execute"><strong>execute</strong></a>(self, inmap)</dt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="geosolver.method.html#Method">Method</a>:<br>
|
|
<dl><dt><a name="AssignMethod-inputs"><strong>inputs</strong></a>(self)</dt><dd><tt>return a list of input variables<br>
|
|
<br>
|
|
If an attribute '_inputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="AssignMethod-outputs"><strong>outputs</strong></a>(self)</dt><dd><tt>return a list of output variables<br>
|
|
<br>
|
|
If an attribute '_outputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="Method">class <strong>Method</strong></a></font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Abstract method<br>
|
|
<br>
|
|
A <a href="#Method">Method</a> is an object that defines input variables, output variables<br>
|
|
and an execute method. This class should be considered abstract.<br>
|
|
Instances (of subclasses of) <a href="#Method">Method</a> must be non-mutable, hashable objects.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="Method-execute"><strong>execute</strong></a>(self, inmap)</dt><dd><tt>Execute method.<br>
|
|
<br>
|
|
Returns a mapping (dictionary) of output variables to values, <br>
|
|
given an input map, mapping input variables to values (dictionary)<br>
|
|
The previous value of the output variable should also be in inmap.<br>
|
|
If the method cannot be executed, it should return an empty map.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Method-inputs"><strong>inputs</strong></a>(self)</dt><dd><tt>return a list of input variables<br>
|
|
<br>
|
|
If an attribute '_inputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="Method-outputs"><strong>outputs</strong></a>(self)</dt><dd><tt>return a list of output variables<br>
|
|
<br>
|
|
If an attribute '_outputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="MethodGraph">class <strong>MethodGraph</strong></a></font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Implementation of a method graph<br>
|
|
<br>
|
|
A method graph is represented by <br>
|
|
a directed bi-partite graph: nodes are either varables or methods. <br>
|
|
Edges run from input variables to methods and from methods to ouput<br>
|
|
variables. <br>
|
|
<br>
|
|
A method graph may not contain cycles. Every variable must be <br>
|
|
determined by at most one constraint.<br>
|
|
<br>
|
|
Methods must be instances of (subclasses of) class <a href="#Method">Method</a>.<br>
|
|
Variables are basically just names, and may be any <br>
|
|
non-mutable, hashable object, e.g. strings.<br>
|
|
Values associated with variables may be of any type.<br>
|
|
<br>
|
|
If no value is explicitly associated with a variable, it defaults to None.<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="MethodGraph-__init__"><strong>__init__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-add_method"><strong>add_method</strong></a>(self, met, prop<font color="#909090">=True</font>)</dt><dd><tt>Add a method.<br>
|
|
<br>
|
|
Iff prop is true then this change and any pending<br>
|
|
changes will be propagated.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-add_variable"><strong>add_variable</strong></a>(self, varname, value<font color="#909090">=None</font>)</dt><dd><tt>Add a variable, optionally with a value</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-clear"><strong>clear</strong></a>(self)</dt><dd><tt>clear methodgraph by removing all variables</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-execute"><strong>execute</strong></a>(self, met)</dt><dd><tt>Execute a method and proagate changes. <a href="#Method">Method</a> must be in Methodgraph</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-get"><strong>get</strong></a>(self, varname)</dt><dd><tt>get the value of a variable</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-methods"><strong>methods</strong></a>(self)</dt><dd><tt>return a list of methods</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-propagate"><strong>propagate</strong></a>(self)</dt><dd><tt>Propagate any pending changes.<br>
|
|
<br>
|
|
Changes are propagated until no changes are left or until<br>
|
|
no more changes can be propagated. This method is called<br>
|
|
from <a href="#MethodGraph-set">set</a>() and <a href="#MethodGraph-add_method">add_method</a>() by default. However, if the<br>
|
|
user so chooses, the methods will not call propagate, and<br>
|
|
the user should call this fucntion at a convenient time.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-rem_method"><strong>rem_method</strong></a>(self, met)</dt><dd><tt>Remove a method</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-rem_variable"><strong>rem_variable</strong></a>(self, varname)</dt><dd><tt>Remove a variable and all methods on that variable</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-set"><strong>set</strong></a>(self, varname, value, prop<font color="#909090">=True</font>)</dt><dd><tt>Set the value of a variable.<br>
|
|
<br>
|
|
Iff prop is true then this change and any pending<br>
|
|
changes will be propagated.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="MethodGraph-variables"><strong>variables</strong></a>(self)</dt><dd><tt>return a list of variables</tt></dd></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="SetMethod">class <strong>SetMethod</strong></a>(<a href="geosolver.method.html#Method">Method</a>)</font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="SetMethod-__init__"><strong>__init__</strong></a>(self, var, value)</dt><dd><tt>new method var := value<br>
|
|
<br>
|
|
keyword arguments:<br>
|
|
var - variable name<br>
|
|
value - any object to be associated with var</tt></dd></dl>
|
|
|
|
<dl><dt><a name="SetMethod-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="SetMethod-execute"><strong>execute</strong></a>(self, inmap)</dt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="geosolver.method.html#Method">Method</a>:<br>
|
|
<dl><dt><a name="SetMethod-inputs"><strong>inputs</strong></a>(self)</dt><dd><tt>return a list of input variables<br>
|
|
<br>
|
|
If an attribute '_inputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="SetMethod-outputs"><strong>outputs</strong></a>(self)</dt><dd><tt>return a list of output variables<br>
|
|
<br>
|
|
If an attribute '_outputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="SubMethod">class <strong>SubMethod</strong></a>(<a href="geosolver.method.html#Method">Method</a>)</font></td></tr>
|
|
|
|
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
|
<td width="100%">Methods defined here:<br>
|
|
<dl><dt><a name="SubMethod-__init__"><strong>__init__</strong></a>(self, a, b, c)</dt><dd><tt>new method c := a - b</tt></dd></dl>
|
|
|
|
<dl><dt><a name="SubMethod-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
|
|
|
<dl><dt><a name="SubMethod-execute"><strong>execute</strong></a>(self, inmap)</dt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="geosolver.method.html#Method">Method</a>:<br>
|
|
<dl><dt><a name="SubMethod-inputs"><strong>inputs</strong></a>(self)</dt><dd><tt>return a list of input variables<br>
|
|
<br>
|
|
If an attribute '_inputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="SubMethod-outputs"><strong>outputs</strong></a>(self)</dt><dd><tt>return a list of output variables<br>
|
|
<br>
|
|
If an attribute '_outputs' has been defined, a new list<br>
|
|
with the contents of that attribute will be returned. <br>
|
|
Subclasses may choose to initialise this variable or to <br>
|
|
override this function.</tt></dd></dl>
|
|
|
|
</td></tr></table> <p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#ffc8d8">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#000000" face="helvetica, arial"><a name="ValidityError">class <strong>ValidityError</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr>
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
<td colspan=2><tt>Error indicating operation violated <a href="#MethodGraph">MethodGraph</a> validity<br> </tt></td></tr>
|
|
<tr><td> </td>
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
<dd><a href="geosolver.method.html#ValidityError">ValidityError</a></dd>
|
|
<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
|
|
<dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd>
|
|
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
|
|
</dl>
|
|
<hr>
|
|
Methods defined here:<br>
|
|
<dl><dt><a name="ValidityError-__init__"><strong>__init__</strong></a>(self, message)</dt><dd><tt>Constructor for <a href="#ValidityError">ValidityError</a><br>
|
|
<br>
|
|
arguments:<br>
|
|
message - message to be displayed</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__str__"><strong>__str__</strong></a>(self)</dt></dl>
|
|
|
|
<hr>
|
|
Data descriptors defined here:<br>
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
</dl>
|
|
<hr>
|
|
Data and other attributes inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
|
|
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object at 0x8145ea0><dd><tt>T.<a href="#ValidityError-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl>
|
|
|
|
<hr>
|
|
Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
|
|
<dl><dt><a name="ValidityError-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#ValidityError-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#ValidityError-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#ValidityError-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#ValidityError-__getslice__">__getslice__</a>(i, j) <==> x[i:j]<br>
|
|
<br>
|
|
Use of negative indices is not supported.</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#ValidityError-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#ValidityError-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl>
|
|
|
|
<dl><dt><a name="ValidityError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
|
|
|
<hr>
|
|
Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
</dl>
|
|
<dl><dt><strong>args</strong></dt>
|
|
</dl>
|
|
<dl><dt><strong>message</strong></dt>
|
|
<dd><tt>exception message</tt></dd>
|
|
</dl>
|
|
</td></tr></table></td></tr></table><p>
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="#eeaa77">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
|
|
|
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
|
<td width="100%"><dl><dt><a name="-test"><strong>test</strong></a>()</dt></dl>
|
|
</td></tr></table>
|
|
</body></html> |