|
From: <zk...@us...> - 2010-06-29 12:02:14
|
Revision: 690
http://pyphant.svn.sourceforge.net/pyphant/?rev=690&view=rev
Author: zklaus
Date: 2010-06-29 12:01:34 +0000 (Tue, 29 Jun 2010)
Log Message:
-----------
Merge branch 'master' into svn-trunk
* master:
Fix: Deals with the ParseQuantities part of #37
Enh: Test for emd5 consist. with FMF import
Fix: DCSource: removed AutoSelect feature
Enh: Reset button for DCSource workers
Cosm: Worker Rep now presented in TreeCtrl
Fix: DCSource
Modified Paths:
--------------
trunk/src/pyphant/pyphant/core/Param.py
trunk/src/pyphant/pyphant/core/Worker.py
trunk/src/pyphant/pyphant/core/WorkerRegistry.py
trunk/src/pyphant/pyphant/quantities/ParseQuantities.py
trunk/src/pyphant/pyphant/wxgui2/WorkerRepository.py
trunk/src/pyphant/pyphant/wxgui2/paramvisualization/CheckBox.py
trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ListSelect.py
trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ParamVisReg.py
trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py
trunk/src/workers/fmfile/fmfile/tests/TestFMFLoader.py
trunk/src/workers/tools/tools/DCSource.py
trunk/src/workers/tools/tools/FCSource.py
trunk/src/workers/tools/tools/SCSource.py
Added Paths:
-----------
trunk/src/workers/fmfile/fmfile/tests/resources/
trunk/src/workers/fmfile/fmfile/tests/resources/fmf/
trunk/src/workers/fmfile/fmfile/tests/resources/fmf/dep.fmf
Modified: trunk/src/pyphant/pyphant/core/Param.py
===================================================================
--- trunk/src/pyphant/pyphant/core/Param.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/core/Param.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -53,11 +53,11 @@
self.expectedValue = expectedValue
-class PossibleValuesChangeExpected(object):
- def __init__(self, param, expectedPVs, autoSelect=False):
+class VisualizerChangeValue(object):
+ def __init__(self, param, **kargs):
self.param = param
- self.expectedPVs = expectedPVs
- self.autoSelect = autoSelect
+ for key, value in kargs.iteritems():
+ setattr(self, key, value)
class ParamChangeRequested(object):
Modified: trunk/src/pyphant/pyphant/core/Worker.py
===================================================================
--- trunk/src/pyphant/pyphant/core/Worker.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/core/Worker.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -43,9 +43,10 @@
class WorkerInfo(object):
## __slots__ = ["name", "createWorker"] #not possible due to pickling restrictions.
- def __init__(self, name, createWorker):
- self.name=name
- self.createWorker=createWorker
+ def __init__(self, cls):
+ self.name = cls.name
+ self.toolBoxName = cls.__module__.split('.')[0]
+ self.createWorker = cls
def plug(returnType):
def setPlug(_plug):
@@ -69,7 +70,7 @@
cls._plugs.append((f, cdict[f]))
super(WorkerFactory, cls).__init__(name, bases, cdict)
if cls.__name__ != 'Worker':
- WorkerFactory.workerRegistry.registerWorker(WorkerInfo(cls.name,cls))
+ WorkerFactory.workerRegistry.registerWorker(WorkerInfo(cls))
class Worker(object):
API = 2
Modified: trunk/src/pyphant/pyphant/core/WorkerRegistry.py
===================================================================
--- trunk/src/pyphant/pyphant/core/WorkerRegistry.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/core/WorkerRegistry.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -42,20 +42,48 @@
import pkg_resources
+class ToolBoxInfo(object):
+ def __init__(self, name):
+ self.name = name
+ self.workerInfos = []
+ self._logger = logging.getLogger("pyphant")
+
+ def sortWorkerInfos(self):
+ self.workerInfos.sort(key=lambda x:x.name.lower())
+
+ def __eq__(self, other):
+ return self.name == other.name
+
+ def __ne__(self, other):
+ return self.name != other.name
+
+ def addWorkerInfo(self, workerInfo):
+ if not workerInfo in self.workerInfos:
+ self.workerInfos.append(workerInfo)
+ self._logger.info("Added worker %s from toolbox %s." \
+ % (workerInfo.name, self.name))
+
+
class WorkerRegistry(singletonmixin.Singleton):
def __init__(self):
- self._workerPool = []
+ self._toolBoxInfoList = []
+ self._toolBoxInfoDict = {}
self._logger = logging.getLogger("pyphant")
self._dirty = True
def registerWorker(self, workerInfo):
- if not workerInfo in self._workerPool:
- self._workerPool.append(workerInfo)
- self._logger.info("added worker")
- else:
- self._logger.info("did nothing")
+ tBI = ToolBoxInfo(workerInfo.toolBoxName)
+ if not tBI in self._toolBoxInfoList:
+ self._toolBoxInfoList.append(tBI)
+ self._toolBoxInfoDict[tBI.name] = tBI
+ self._toolBoxInfoDict[tBI.name].addWorkerInfo(workerInfo)
- def getWorkers(self):
+ def sortToolBoxInfos(self):
+ for tBI in self._toolBoxInfoList:
+ tBI.sortWorkerInfos()
+ self._toolBoxInfoList.sort(key=lambda x: x.name.lower())
+
+ def getToolBoxInfoList(self):
if self._dirty:
for worker in pkg_resources.iter_entry_points("pyphant.workers"):
wm = worker.load()
@@ -75,5 +103,6 @@
"worker archive " + worker.module_name \
+ " contains invalid worker " + module \
+ ": " + str(e))
+ self.sortToolBoxInfos()
self._dirty = False
- return self._workerPool
+ return self._toolBoxInfoList
Modified: trunk/src/pyphant/pyphant/quantities/ParseQuantities.py
===================================================================
--- trunk/src/pyphant/pyphant/quantities/ParseQuantities.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/quantities/ParseQuantities.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -73,7 +73,12 @@
unit = Quantity(unit.encode('utf-8'))
elif FMFversion=='1.0':
unit1_0 = PhysicalQuantity(unit.encode('utf-8'))
+ unit_base = Quantity(str(unit1_0.inBaseUnits()))
unit = Quantity(str(unit1_0))
+ if unit_base != unit:
+ unit = unit_base
+ _logger.warn('Usage of old unit "%s" required '
+ 'conversion to base units.' % unit1_0)
except:
unit = float(unit)
return unit
Modified: trunk/src/pyphant/pyphant/wxgui2/WorkerRepository.py
===================================================================
--- trunk/src/pyphant/pyphant/wxgui2/WorkerRepository.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/wxgui2/WorkerRepository.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -39,40 +39,28 @@
import wx
import cPickle
-import pyphant.core.WorkerRegistry
+from pyphant.core.WorkerRegistry import WorkerRegistry
-class WorkerRepository(wx.ScrolledWindow):
- def __init__(self, parent, id=-1,
- pos=wx.DefaultPosition,
- size=wx.DefaultSize,
- style=0):
- wx.ScrolledWindow.__init__(self, parent, id)
- workerRegistry = pyphant.core.WorkerRegistry.WorkerRegistry
- self._workerRegistry = workerRegistry.getInstance()
- self._boxSizer = wx.BoxSizer(wx.VERTICAL)
- self.initFoldPanelBar()
- self.SetSizer(self._boxSizer)
- self.SetScrollRate(1, 1)
- self._boxSizer.SetVirtualSizeHints(self)
- def initFoldPanelBar(self):
- map(self.addWorkerButton, self._workerRegistry.getWorkers())
+class WorkerRepository(wx.TreeCtrl):
+ def __init__(self, *args, **kargs):
+ wx.TreeCtrl.__init__(self, *args, **kargs)
+ tBIL = WorkerRegistry.getInstance().getToolBoxInfoList()
+ rootId = self.AddRoot('toolboxes')
+ for tBI in tBIL:
+ toolBoxId = self.AppendItem(rootId, tBI.name)
+ for workerInfo in tBI.workerInfos:
+ wIId = self.AppendItem(toolBoxId, workerInfo.name)
+ self.SetItemData(wIId, wx.TreeItemData(workerInfo))
+ self.Bind(wx.EVT_TREE_BEGIN_DRAG,
+ self.onDragInit, id=self.GetId())
- def addWorkerButton(self, workerInfo):
- btn = WorkerButton(self, workerInfo)
- self._boxSizer.Add(btn, 1, wx.EXPAND, wx.ALL, 10)
-
-
-class WorkerButton(wx.Button):
- def __init__(self, parent, workerInfo):
- name = workerInfo.name
- wx.Button.__init__(self, parent, label=name)
- self._workerInfo = workerInfo
- self.Bind(wx.EVT_LEFT_DOWN, self.onLeftDown)
-
- def onLeftDown(self, evt):
- dropSource = wx.DropSource(self)
- pickledObj = cPickle.dumps(self._workerInfo)
- data = wx.TextDataObject(pickledObj)
- dropSource.SetData(data)
- dragResult = dropSource.DoDragDrop(True)
+ def onDragInit(self, event):
+ workerInfo = self.GetItemData(event.Item).Data
+ if workerInfo is not None:
+ dropSource = wx.DropSource(self)
+ pickledObj = cPickle.dumps(workerInfo)
+ data = wx.TextDataObject(pickledObj)
+ dropSource.SetData(data)
+ dragResult = dropSource.DoDragDrop(True)
+ event.Skip()
Modified: trunk/src/pyphant/pyphant/wxgui2/paramvisualization/CheckBox.py
===================================================================
--- trunk/src/pyphant/pyphant/wxgui2/paramvisualization/CheckBox.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/wxgui2/paramvisualization/CheckBox.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -38,7 +38,10 @@
# $Source$
import wx
+from pyphant.core.Param import (
+ ParamChangeExpected, VisualizerChangeValue)
+
class CheckBox(wx.CheckBox):
def __init__(self, parent, param, validator):
wx.CheckBox.__init__(self, parent, validator=validator)
@@ -46,3 +49,19 @@
def getValue(self):
return self.GetValue()
+
+class InstantCheckBox(CheckBox):
+ def __init__(self, parent, param, validator):
+ CheckBox.__init__(self, parent, param, validator)
+ self.param = param
+ self.Bind(wx.EVT_CHECKBOX, self.onCheck)
+ param._eventDispatcher.registerExclusiveListener(
+ self.onVCV, VisualizerChangeValue)
+
+ def onCheck(self, Event):
+ pce = ParamChangeExpected(self.param, expectedValue=self.getValue())
+ self.param._eventDispatcher.dispatchEvent(pce)
+ Event.Skip()
+
+ def onVCV(self, event):
+ self.SetValue(event.value)
Modified: trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ListSelect.py
===================================================================
--- trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ListSelect.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ListSelect.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -40,7 +40,7 @@
import wx
from wx import EVT_CHOICE
from pyphant.core.Param import (
- ParamChangeExpected, PossibleValuesChangeExpected)
+ ParamChangeExpected, VisualizerChangeValue)
class ListSelect(wx.Choice):
def __init__(self, parent, param, validator):
@@ -64,7 +64,7 @@
"""
This class dispatches the ParamChangeExpected event as soon as
the user selects a new value and listens for the
- PossibleValueChangeExpected event which should be raised
+ VisualizerChangeValue event which should be raised
if the possible values for the underlying ListSelect
need to be updated.
"""
@@ -74,23 +74,19 @@
self.param = param
self.possibleValues = param.possibleValues
param._eventDispatcher.registerExclusiveListener(
- self.onPVCE, PossibleValuesChangeExpected)
+ self.onVCV, VisualizerChangeValue)
- def onPVCE(self, event):
- value = self.data[self.GetStringSelection()]
- assert value in event.expectedPVs, "%s not in %s" % (value,
- event.expectedPVs)
- self.data = dict([(str(val), val) for val in event.expectedPVs])
- self.possibleValues = event.expectedPVs
- self.SetItems(map(str, event.expectedPVs))
- if event.autoSelect and len(event.expectedPVs) == 2:
- self.SetSelection(1)
- pce = ParamChangeExpected(
- self.param, expectedValue=self.data[self.GetStringSelection()])
- pce.norefresh = True
- self.param._eventDispatcher.dispatchEvent(pce)
+ def onVCV(self, event):
+ if not hasattr(event, 'value'):
+ value = self.data[self.GetStringSelection()]
else:
- self.SetValue(value)
+ value = event.value
+ assert value in event.possibleValues, "%s not in %s" \
+ % (value, event.possibleValues)
+ self.data = dict([(str(val), val) for val in event.possibleValues])
+ self.possibleValues = event.possibleValues
+ self.SetItems(map(str, event.possibleValues))
+ self.SetValue(value)
def onChoice(self, event):
event.Skip()
Modified: trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ParamVisReg.py
===================================================================
--- trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ParamVisReg.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/wxgui2/paramvisualization/ParamVisReg.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -94,6 +94,7 @@
(" ", None, OneLineStringField.OLSF),
(" ", Connectors.SUBTYPE_FILE, FileButton.FileButton),
(True, None, CheckBox.CheckBox),
+ (True, Connectors.SUBTYPE_INSTANT, CheckBox.InstantCheckBox),
([], None, ListSelect.ListSelect),
([], Connectors.SUBTYPE_INSTANT, ListSelect.InstantSelect)
]
Modified: trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py
===================================================================
--- trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/pyphant/pyphant/wxgui2/wxPyphantApplication.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -60,7 +60,8 @@
import wx.aui
import sogl
import pyphant.wxgui2.paramvisualization.ParamVisReg as ParamVisReg
-import pyphant.core.PyTablesPersister
+from pyphant.core.PyTablesPersister import (loadRecipeFromHDF5File,
+ saveRecipeToHDF5File)
import WorkerRepository
import ConfigureFrame
import platform
@@ -128,43 +129,31 @@
self._statusBar = self.CreateStatusBar()
self._wxPyphantApp = _wxPyphantApp
self._initMenuBar()
- self._initSash()
+ self._initWorkerRep()
self.recipeState = None
self.onOpenCompositeWorker(None)
self._initAui()
- self._workerRepository.Bind(wx.EVT_SASH_DRAGGED_RANGE,
- self.onFoldPanelBarDrag,
- id=self.ID_WINDOW_TOP,
- id2=self.ID_WINDOW_BOTTOM)
- #self.Bind(wx.EVT_SIZE, self.onSize)
self.compositeWorkerStack = []
- def _initSash(self):
- self._workerRepository = wx.SashLayoutWindow(
- self, self.ID_WINDOW_RIGHT, wx.DefaultPosition, wx.Size(220,1000),
- wx.NO_BORDER)
- #self._workerRepository.SetDefaultSize(wx.Size(220,1000))
- #self._workerRepository.SetOrientation(wx.LAYOUT_VERTICAL)
- #self._workerRepository.SetAlignment(wx.LAYOUT_RIGHT)
- #self._workerRepository.SetSashVisible(wx.SASH_LEFT, True)
- #self._workerRepository.SetExtraBorderSize(10)
+ def _initWorkerRep(self):
try:
- WorkerRepository.WorkerRepository(self._workerRepository)
+ self._workerRepository = WorkerRepository.WorkerRepository(
+ self, self.ID_WINDOW_RIGHT, wx.DefaultPosition,
+ wx.Size(220, -1))
+ self._workerRepository.Expand(self._workerRepository.RootItem)
except:
import sys
- self._wxPyphantApp._logger.debug(u"An exception occured while "\
- "loading the toolboxes.",
- exc_info=sys.exc_info())
- wx.MessageBox("An error has occurred while importing "\
- "the toolboxes.\nPlease investigate the logfile "\
- "for further details.\nThe logfile is located at %s\n"\
- "You may also try to update and restart wxPyphant."\
- % os.path.join(LOGDIR, 'pyphant.log'),
- "Toolbox Error!")
- self._workerRepository = wx.SashLayoutWindow(
- self, self.ID_WINDOW_RIGHT, wx.DefaultPosition,
- wx.Size(220,1000),
- wx.NO_BORDER)
+ self._wxPyphantApp._logger.debug(
+ u"An exception occured while loading the toolboxes.",
+ exc_info=sys.exc_info())
+ wx.MessageBox(
+ "An error has occurred while importing "\
+ "the toolboxes.\nPlease investigate the logfile "\
+ "for further details.\nThe logfile is located at %s\n"\
+ "You may also try to update and restart wxPyphant."\
+ % os.path.join(LOGDIR, 'pyphant.log'),
+ "Toolbox Error!")
+ self._workerRepository = wx.TreeCtrl(self)
def _initAui(self):
self._auiManager = wx.aui.AuiManager(self)
@@ -175,10 +164,9 @@
def OnClick(self, event):
logbuffer.flush()
event.Skip()
- self._logpane = ClickableText(self, -1, "",
- wx.DefaultPosition, wx.Size(640, 200),
- wx.NO_BORDER | wx.TE_MULTILINE \
- | wx.TE_READONLY)
+ self._logpane = ClickableText(
+ self, -1, "", wx.DefaultPosition, wx.Size(640, 200),
+ wx.NO_BORDER | wx.TE_MULTILINE | wx.TE_READONLY)
class WxHandler(logging.Handler):
def __init__(self, ctrl):
logging.Handler.__init__(self)
@@ -201,25 +189,8 @@
'Worker Repository')
self._auiManager.AddPane(self._remainingSpace, wx.CENTER, 'Main')
wrpane = self._auiManager.GetPane(self._workerRepository)
- wrpane.Floatable(False)
- wrpane.Movable(False)
self._auiManager.Update()
- def onSize(self, event):
- wx.LayoutAlgorithm().LayoutWindow(self,self._remainingSpace)
- event.Skip()
-
- def onFoldPanelBarDrag(self, event):
- if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
- return
- if event.GetId() == self.ID_WINDOW_RIGHT:
- self._workerRepository.SetDefaultSize(
- wx.Size(event.GetDragRect().width, 1000))
- # Leaves bits of itself behind sometimes
- #wx.LayoutAlgorithm().LayoutWindow(self, self._remainingSpace)
- self._remainingSpace.Refresh()
- event.Skip()
-
def onOpenCompositeWorker(self, event):
if not self._wxPyphantApp.pathToRecipe:
if pltform == 'Linux' or pltform == 'Darwin':
@@ -250,20 +221,22 @@
if self._wxPyphantApp.pathToRecipe[-3:] == '.h5':
if os.path.exists(self._wxPyphantApp.pathToRecipe):
try:
- recipe = pyphant.core.PyTablesPersister.loadRecipeFromHDF5File(
+ recipe = loadRecipeFromHDF5File(
self._wxPyphantApp.pathToRecipe)
- self._remainingSpace = PyphantCanvas.PyphantCanvas(self, recipe)
+ self._remainingSpace = PyphantCanvas.PyphantCanvas(
+ self, recipe)
except:
- self._wxPyphantApp._logger.debug(u"An exception occured while "\
- "loading a recipe.",
- exc_info=sys.exc_info())
- wx.MessageBox("An error has occurred while opening "\
- "the recipe.\nRecipe has been set to an "\
- "empty file in order to prevent data loss.\n"\
- "Please investigate the logfile "\
- "for further details.\nThe logfile is located at %s"\
- % os.path.join(LOGDIR, 'pyphant.log'),
- "Recipe broken, unknown format or outdated!")
+ self._wxPyphantApp._logger.debug(
+ u"An exception occured while loading a recipe.",
+ exc_info=sys.exc_info())
+ wx.MessageBox(
+ "An error has occurred while opening "\
+ "the recipe.\nRecipe has been set to an "\
+ "empty file in order to prevent data loss.\n"\
+ "Please investigate the logfile "\
+ "for further details.\nThe logfile is located at %s"\
+ % os.path.join(LOGDIR, 'pyphant.log'),
+ "Recipe broken, unknown format or outdated!")
self._wxPyphantApp.pathToRecipe += ".error.h5"
self._remainingSpace = PyphantCanvas.PyphantCanvas(self)
else:
@@ -281,10 +254,9 @@
self.recipeState = 'dirty'
def onSaveCompositeWorker(self, event=None):
- pyphant.core.PyTablesPersister.saveRecipeToHDF5File(
- self._remainingSpace.diagram.recipe,
- self._wxPyphantApp.pathToRecipe,
- self._fileMenu.IsChecked(wx.ID_FILE4))
+ saveRecipeToHDF5File(self._remainingSpace.diagram.recipe,
+ self._wxPyphantApp.pathToRecipe,
+ self._fileMenu.IsChecked(wx.ID_FILE4))
self.recipeState = 'clean'
def onSaveAsCompositeWorker(self, event=None):
@@ -296,10 +268,9 @@
filename = dlg.GetPath()
if not filename.endswith(".h5"):
filename += ".h5"
- pyphant.core.PyTablesPersister.saveRecipeToHDF5File(
+ saveRecipeToHDF5File(
self._remainingSpace.diagram.recipe,
- filename,
- self._fileMenu.IsChecked(wx.ID_FILE4))
+ filename, self._fileMenu.IsChecked(wx.ID_FILE4))
self._wxPyphantApp.pathToRecipe = filename
self.recipeState = 'clean'
from pyphant.core.WebInterface import shorten
Modified: trunk/src/workers/fmfile/fmfile/tests/TestFMFLoader.py
===================================================================
--- trunk/src/workers/fmfile/fmfile/tests/TestFMFLoader.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/workers/fmfile/fmfile/tests/TestFMFLoader.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -41,7 +41,7 @@
from pyphant.core.DataContainer import FieldContainer,assertEqual
from pyphant.quantities import Quantity
from pyphant.quantities.ParseQuantities import str2unit
-
+
class FieldContainerCondenseDim(unittest.TestCase):
def setUp(self):
self.x = numpy.linspace(0,0.9,10)
@@ -135,13 +135,13 @@
created: 2010-03-16
place: ICE 676, Offenburg-Karlsruhe, Germany
[Mathematical and Physical Constants]
-Area of unit circle: pi = 3.1415926535897931
+Area of unit circle: pi = 3.1415926535897931
Speed of light: c = 299792458 m/s
Permeability of vacuum: \mu_0 = 4.e-7 pi*N/A**2
Permittivity of vacuum: \eps_0 = 1.0 1/mu0/c**2
-Gravitational constant: Grav = 6.67259e-11 m**3/kg/s**2
+Gravitational constant: Grav = 6.67259e-11 m**3/kg/s**2
Planck constant: hplanck = 6.6260755e-34 J*s
-Planck constant / 2pi: hbar = 0.5 hplanck/pi
+Planck constant / 2pi: hbar = 0.5 hplanck/pi
Elementary charge: e = 1.60217733e-19 C
Electron mass: m_e = 9.1093897e-31 kg
Proton mass: m_p = 1.6726231e-27 kg
@@ -163,7 +163,7 @@
Missing Value: V_m
Infinite Value: V_i
[*data: T]
-H_2 1 1. 1e1 1+0j nan inf
+H_2 1 1. 1e1 1+0j nan inf
O_2 2 .2 2E1 2+.1j NaN INF
O 2 2 .2 2E1 2.+2j NAN Inf
[*data definitions: M]
@@ -209,14 +209,14 @@
created: 2010-03-17
place: ICE 604, Offenburg-Karlsruhe, Germany
[Mathematical and Physical Constants]
-Area of unit circle: pi = 3.1415926535897931
+Area of unit circle: pi = 3.1415926535897931
Speed of light: c = 299792458 m/s
Permeability of vacuum: \mu_0 = 4.e-7 pi*N/A**2
Permittivity of vacuum: \eps_0 = 1.0 1/mu0/c**2
Faraday constant: Fa = 96485.3399 C/mol
-Gravitational constant: G = 6.67428e-11 m**3/kg/s**2
+Gravitational constant: G = 6.67428e-11 m**3/kg/s**2
Planck constant: h = 6.62606896e-34 J*s
-Planck constant / 2pi: hbar = 0.5 h/pi
+Planck constant / 2pi: hbar = 0.5 h/pi
Elementary charge: e = 1.602176487e-19 C
Electron mass: m_e = 9.10938215e-31 kg
Proton mass: m_p = 1.672621637e-27 kg
@@ -240,7 +240,7 @@
Missing Value: V_m
Infinite Value: V_i
[*data: T]
-H_2 1 1. 1e1 1+0j nan inf
+H_2 1 1. 1e1 1+0j nan inf
O_2 2 .2 2E1 2+.1j NaN INF
O 2 2 .2 2E1 2.+2j NAN Inf
[*data definitions: M]
@@ -272,7 +272,45 @@
self.assertEqual(consts[u'Parsec'][1],str2unit("1 pc",FMFversion="1.1"))
self.assertEqual(consts[u'US gallon'][1],str2unit("1 galUS",FMFversion="1.1"))
self.assertEqual(consts[u'Atomic mass units'][1],str2unit("1 u",FMFversion="1.1"))
-
+
+
+class Emd5ConsistencyTestCase(unittest.TestCase):
+ def setUp(self):
+ from fmfile import __path__ as path
+ import os
+ self.filename = os.path.join(path[0], 'tests', 'resources',
+ 'fmf','dep.fmf')
+
+ def testImportFMF(self):
+ from fmfile import FMFLoader
+ table = FMFLoader.loadFMFFromFile(self.filename)
+ print "Testing imported SampleContainer for consistency..."
+ for column in ['y0', 'y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8']:
+ self.assertEqual(table[column].dimensions[0].id,
+ table['x'].id)
+
+ def testRegisterFMF(self):
+ from pyphant.core.KnowledgeManager import KnowledgeManager
+ kmanager = KnowledgeManager.getInstance()
+ table_id = kmanager.registerFMF(self.filename, temporary=True)
+ table = kmanager.getDataContainer(table_id)
+ print "Testing registered SampleContainer for consistency..."
+ for column in ['y0', 'y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8']:
+ self.assertEqual(table[column].dimensions[0].id,
+ table['x'].id)
+
+ def testRegisterFMFSummary(self):
+ from pyphant.core.KnowledgeManager import KnowledgeManager
+ kmanager = KnowledgeManager.getInstance()
+ table_id = kmanager.registerFMF(self.filename, temporary=True)
+ table = kmanager.getDataContainer(table_id)
+ print "Testing registered SampleContainer summary for consistency..."
+ for column in ['y0', 'y1', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8']:
+ summary = kmanager.getSummary(table[column].id)
+ emd5 = summary['dimensions'][0]
+ self.assertEqual(emd5, table['x'].id)
+
+
if __name__ == "__main__":
import sys
if len(sys.argv) == 1:
Added: trunk/src/workers/fmfile/fmfile/tests/resources/fmf/dep.fmf
===================================================================
--- trunk/src/workers/fmfile/fmfile/tests/resources/fmf/dep.fmf (rev 0)
+++ trunk/src/workers/fmfile/fmfile/tests/resources/fmf/dep.fmf 2010-06-29 12:01:34 UTC (rev 690)
@@ -0,0 +1,41 @@
+; -*- fmf-version: 1.0; delimiter: whitespace -*-
+[*reference]
+title: Import Test
+creator: Alexander Held
+created: 2010-25-06 14:15:00
+place: Uni Freiburg FMF
+
+[*data definitions]
+x: x [m]
+y0: y0(x) [m]
+y1: y1(x) [m]
+y2: y2(x) [m]
+y3: y3(x) [m]
+y4: y4(x) [m]
+y5: y5(x) [m]
+y6: y6(x) [m]
+y7: y7(x) [m]
+y8: y8(x) [m]
+
+[*data]
+0 0 1 2 3 4 5 6 7 8
+1 0 1 2 3 4 5 6 7 8
+2 0 1 2 3 4 5 6 7 8
+3 0 1 2 3 4 5 6 7 8
+;4 0 1 2 3 4 5 6 7 8
+5 0 1 2 3 4 5 6 7 8
+6 0 1 2 3 4 5 6 7 8
+7 0 1 2 3 4 5 6 7 8
+8 0 1 2 3 4 5 6 7 8
+9 0 1 2 3 4 5 6 7 8
+10 0 1 2 3 4 5 6 7 8
+11 0 1 2 3 4 5 6 7 8
+12 0 1 2 3 4 5 6 7 8
+13 0 1 2 3 4 5 6 7 8
+14 0 1 2 3 4 5 6 7 8
+15 0 1 2 3 4 5 6 7 8
+16 0 1 2 3 4 5 6 7 8
+;17 0 1 2 3 4 5 6 7 8
+18 0 1 2 3 4 5 6 7 8
+19 0 1 2 3 4 5 6 7 8
+20 0 1 2 3 4 5 6 7 8
Modified: trunk/src/workers/tools/tools/DCSource.py
===================================================================
--- trunk/src/workers/tools/tools/DCSource.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/workers/tools/tools/DCSource.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -40,7 +40,7 @@
from pyphant.core.KnowledgeManager import KnowledgeManager
from pyphant.core.Param import (
- ParamChangeExpected, PossibleValuesChangeExpected, ParamOverridden)
+ ParamChangeExpected, VisualizerChangeValue, ParamOverridden)
ANYSTR = u"-- any --"
@@ -53,18 +53,21 @@
self.dc_type = dc_type
self.expectedValues = {}
for name, param in self._params.iteritems():
- if name in ["name"]:
+ if name == 'name':
continue
param.registerListener(self.onPCE, ParamChangeExpected)
param.registerListener(self.onPO, ParamOverridden)
self.expectedValues[name] = param.value
def onPCE(self, event):
- if event.expectedValue != self.expectedValues[event.param.name]:
+ if event.param.name == 'reset' and event.expectedValue:
+ self.refreshParams(update=False, reset=True)
+ vcv = VisualizerChangeValue(event.param, value=False)
+ event.param._eventDispatcher.dispatchEvent(vcv)
+ elif event.param.name != 'reset' and \
+ event.expectedValue != self.expectedValues[event.param.name]:
self.expectedValues[event.param.name] = event.expectedValue
- if not hasattr(event, 'norefresh'):
- autoSelect = event.expectedValue != ANYSTR
- self.refreshParams(update=False, autoSelect=autoSelect)
+ self.refreshParams(update=False)
def onPO(self, event):
self.expectedValues[event.param.name] = event.newValue
@@ -79,7 +82,7 @@
search_dict.update(dict(
[self.getKeyValue(key, val, name) \
for key, val in self.expectedValues.iteritems() \
- if key not in ['name', name] and val != ANYSTR]))
+ if key not in ['name', 'reset', name] and val != ANYSTR]))
if name == 'dim_of':
search_dict = {'type':'field', 'has_dim':search_dict}
elif name == 'col_of':
@@ -96,21 +99,27 @@
else:
return name
- def refreshParams(self, subscriber=None, update=True, autoSelect=True):
+ def refreshParams(self, subscriber=None, update=True, reset=False):
if update:
self.expectedValues = dict(
[(name, param.value) for name, param \
- in self._params.iteritems() if name != 'name'])
+ in self._params.iteritems() if name not in ['name', 'reset']])
+ elif reset:
+ self.expectedValues = dict(
+ [(name, ANYSTR) for name in self._params.iterkeys() \
+ if name not in ['name', 'reset']])
kmanager = KnowledgeManager.getInstance()
for name, param in self._params.iteritems():
- if name == 'name':
+ if name in ['name', 'reset']:
continue
search_dict = self.getSearchDict(name)
newEVs = [[ANYSTR]]
newEVs.extend(kmanager.search(
[self.getResKey(name)], search_dict=search_dict, distinct=True))
newEVs = [newEV[0] for newEV in newEVs]
- param._eventDispatcher.dispatchEvent(
- PossibleValuesChangeExpected(param, newEVs, autoSelect))
+ event = VisualizerChangeValue(param, possibleValues=newEVs)
+ if reset:
+ event.value = ANYSTR
+ param._eventDispatcher.dispatchEvent(event)
if update:
param.possibleValues = newEVs
Modified: trunk/src/workers/tools/tools/FCSource.py
===================================================================
--- trunk/src/workers/tools/tools/FCSource.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/workers/tools/tools/FCSource.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -53,16 +53,17 @@
VERSION = 1
REVISION = "$Revision$"[11:-1]
name = "FieldContainer"
- _params = [("machine", u"machine ==", [ANYSTR], SUBTYPE_INSTANT),
- ("creator", u"and creator ==", [ANYSTR], SUBTYPE_INSTANT),
- ("longname", u"and longname ==", [ANYSTR], SUBTYPE_INSTANT),
+ _params = [("longname", u"and longname ==", [ANYSTR], SUBTYPE_INSTANT),
("shortname", u"and shortname ==", [ANYSTR], SUBTYPE_INSTANT),
("unit", u"and unit is compatible to", [ANYSTR],
SUBTYPE_INSTANT),
("has_dim", u"and has dimension", [ANYSTR], SUBTYPE_INSTANT),
("col_of", u"and is column of", [ANYSTR], SUBTYPE_INSTANT),
("dim_of", u"and is dimension of", [ANYSTR], SUBTYPE_INSTANT),
- ("id", u"and emd5 ==", [ANYSTR], SUBTYPE_INSTANT)]
+ ("machine", u"machine ==", [ANYSTR], SUBTYPE_INSTANT),
+ ("creator", u"and creator ==", [ANYSTR], SUBTYPE_INSTANT),
+ ("id", u"and emd5 ==", [ANYSTR], SUBTYPE_INSTANT),
+ ('reset', u'clear all parameters', False, SUBTYPE_INSTANT)]
def __init__(self, *args, **kargs):
Worker.Worker.__init__(self, *args, **kargs)
Modified: trunk/src/workers/tools/tools/SCSource.py
===================================================================
--- trunk/src/workers/tools/tools/SCSource.py 2010-06-22 10:09:24 UTC (rev 689)
+++ trunk/src/workers/tools/tools/SCSource.py 2010-06-29 12:01:34 UTC (rev 690)
@@ -53,13 +53,14 @@
VERSION = 1
REVISION = "$Revision$"[11:-1]
name = "SampleContainer"
- _params = [("machine", u"machine ==", [ANYSTR], SUBTYPE_INSTANT),
- ("creator", u"and creator ==", [ANYSTR], SUBTYPE_INSTANT),
- ("longname", u"and longname ==", [ANYSTR], SUBTYPE_INSTANT),
+ _params = [("longname", u"and longname ==", [ANYSTR], SUBTYPE_INSTANT),
("shortname", u"and shortname ==", [ANYSTR], SUBTYPE_INSTANT),
("has_col", u"and has column", [ANYSTR], SUBTYPE_INSTANT),
("col_of", u"and is column of", [ANYSTR], SUBTYPE_INSTANT),
- ("id", u"and emd5 ==", [ANYSTR], SUBTYPE_INSTANT)]
+ ("machine", u"machine ==", [ANYSTR], SUBTYPE_INSTANT),
+ ("creator", u"and creator ==", [ANYSTR], SUBTYPE_INSTANT),
+ ("id", u"and emd5 ==", [ANYSTR], SUBTYPE_INSTANT),
+ ('reset', u'clear all parameters', False, SUBTYPE_INSTANT)]
def __init__(self, *args, **kargs):
Worker.Worker.__init__(self, *args, **kargs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|