|
From: <li...@us...> - 2008-12-05 12:22:17
|
Revision: 580
http://pyphant.svn.sourceforge.net/pyphant/?rev=580&view=rev
Author: liehr
Date: 2008-12-05 11:45:47 +0000 (Fri, 05 Dec 2008)
Log Message:
-----------
Enhanced method .getWorkers of CompositeWorker class
If a recipe contains several workers from the same worker class
a specific worker can be selected via the .getWorker() method
by naming its precursor worker.
Modified Paths:
--------------
trunk/doc/demo/viewOSC.py
trunk/src/pyphant/pyphant/core/CompositeWorker.py
Modified: trunk/doc/demo/viewOSC.py
===================================================================
--- trunk/doc/demo/viewOSC.py 2008-12-05 11:45:16 UTC (rev 579)
+++ trunk/doc/demo/viewOSC.py 2008-12-05 11:45:47 UTC (rev 580)
@@ -125,7 +125,7 @@
worker = recipe.getWorkers("Slicing")[0]
worker.paramDim1.value=freqRange
if scale != None:
- worker = recipe.getWorkers("Multi Resolution Analyser")[0]
+ worker = recipe.getWorkers("Multi Resolution Analyser","Slicing")[0]
worker.paramScale.value=scale
def initPylab(postscript):
@@ -170,7 +170,7 @@
noisyAbsorption = worker.plugExtract.getResult()
worker = recipe.getWorkers("Coat Thickness Model")[0]
simulation = worker.plugCalcAbsorption.getResult()
- worker = recipe.getWorkers("Multi Resolution Analyser")[0]
+ worker = recipe.getWorkers("Multi Resolution Analyser","Slicing")[0]
minimaPos = worker.plugMra.getResult().inUnitsOf(simulation.dimensions[1])
worker = recipe.getWorkers("Add Column")[0]
table = worker.plugCompute.getResult(subscriber=TextSubscriber("Add Column"))
@@ -204,7 +204,7 @@
noisyAbsorption = worker.plugExtract.getResult()
worker = recipe.getWorkers("Coat Thickness Model")[0]
simulation = worker.plugCalcAbsorption.getResult()
- worker = recipe.getWorkers("Multi Resolution Analyser")[0]
+ worker = recipe.getWorkers("Multi Resolution Analyser","Slicing")[0]
minimaPos = worker.plugMra.getResult().inUnitsOf(simulation.dimensions[1])
worker = recipe.getWorkers("Add Column")[0]
table = worker.plugCompute.getResult(subscriber=TextSubscriber("Add Column"))
@@ -242,7 +242,7 @@
functional = worker.plugCompute.getResult()
worker = recipe.getWorkers("Coat Thickness Model")[0]
simulation = worker.plugCalcAbsorption.getResult()
- worker = recipe.getWorkers("Multi Resolution Analyser")[0]
+ worker = recipe.getWorkers("Multi Resolution Analyser","Slicing")[0]
minimaPos = worker.plugMra.getResult().inUnitsOf(simulation.dimensions[1])
worker = recipe.getWorkers("Add Column")[0]
table = worker.plugCompute.getResult(subscriber=TextSubscriber("Add Column"))
@@ -264,7 +264,7 @@
table = worker.plugCompute.getResult(subscriber=TextSubscriber("Add Column"))
thickness = table[u"thickness"]
index = curvNo2Index(table[u"pixel"], curvNo)
- worker = recipe.getWorkers("Multi Resolution Analyser")[0]
+ worker = recipe.getWorkers("Multi Resolution Analyser","Slicing")[0]
minimaPos = worker.plugMra.getResult().inUnitsOf(simulation.dimensions[1])
visualizer = ImageVisualizer(simulation, False)
ordinate = simulation.dimensions[1].data
@@ -285,7 +285,7 @@
yPos = table[u"vertical_table_position"]
thickness = table[u"thickness"]
cols = [index, xPos, yPos, thickness]
- worker = recipe.getWorkers("Multi Resolution Analyser")[0]
+ worker = recipe.getWorkers("Multi Resolution Analyser","Slicing")[0]
minimaPos = worker.plugMra.getResult().inUnitsOf(simulation.dimensions[1])
import numpy
data = numpy.vstack([ c.data for c in cols]
Modified: trunk/src/pyphant/pyphant/core/CompositeWorker.py
===================================================================
--- trunk/src/pyphant/pyphant/core/CompositeWorker.py 2008-12-05 11:45:16 UTC (rev 579)
+++ trunk/src/pyphant/pyphant/core/CompositeWorker.py 2008-12-05 11:45:47 UTC (rev 580)
@@ -110,13 +110,18 @@
self._sinks.remove(worker)
self._notifyListeners(WorkerRemovedEvent(worker, data))
- def getWorkers(self,desiredWorker=''):
+ def getWorkers(self,desiredWorker='',precursor=None):
if desiredWorker == '':
result = self._workers
else:
result = [w for w in self._workers if w.name == desiredWorker]
if result == []:
raise ValueError, "Recipe does not contain Worker %s" % desiredWorker
+ if precursor:
+ result = [worker for worker in result
+ if precursor in
+ [socket._plug.worker.name for socket in worker.getSockets()]
+ ]
return result
def getSources(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|