def testAppend(self): handler = H5FH(self.appscFilename, 'a') with handler: handler.saveDataContainer(self.sc) fcLoaded = handler.loadDataContainer(self.fc.id) scLoaded = handler.loadDataContainer(self.sc.id) self.assertEqual(self.fc, fcLoaded) self.assertEqual(self.sc, scLoaded)
def setUp(self): FieldContainerTestCase.setUp(self) osHandle, self.rofcFilename = mkstemp( suffix='.h5', prefix='pyphantH5FileHandlerTest') os.close(osHandle) handler = H5FH(self.rofcFilename, 'w') with handler: handler.saveDataContainer(self.fc)
def testSaveLoadRecipe(self): from pyphant.core.CompositeWorker import CompositeWorker from pyphant.core.WorkerRegistry import WorkerRegistry from itertools import chain recipe = CompositeWorker(annotations={'foo': 42.0, 'bar': u'Hääh?'}) wreg = WorkerRegistry.getInstance() workerInfos = [t.workerInfos for t in wreg.getToolBoxInfoList()] for wInfo in chain(*workerInfos): worker = wInfo.createWorker() recipe.addWorker(worker) with H5FH(self.path, 'w') as handler: handler.saveRecipe(recipe) with H5FH(self.path, 'r') as handler: loadedRecipe = handler.loadRecipe() loadedWorkers = loadedRecipe.getWorkers() workers = recipe.getWorkers() self.assertEqual(len(loadedWorkers), len(workers)) workerNames = [w.name for w in workers] loadedWorkerNames = [w.name for w in loadedWorkers] for name in loadedWorkerNames: self.assertTrue(name in workerNames) self.assertEqual(recipe._annotations, loadedRecipe._annotations)
def testSummary(self): handler = H5FH(self.summFilename, 'r') with handler: summarydict = handler.loadSummary() scsummary = summarydict[self.sc.id] fcsummary = summarydict[self.fc.id] self.assertEqual(scsummary['id'], self.sc.id) self.assertEqual(fcsummary['id'], self.fc.id) self.assertEqual(scsummary['longname'], self.sc.longname) self.assertEqual(fcsummary['longname'], self.fc.longname) self.assertEqual(scsummary['shortname'], self.sc.shortname) self.assertEqual(fcsummary['shortname'], self.fc.shortname) self.assertEqual(scsummary['creator'], self.sc.creator) self.assertEqual(fcsummary['creator'], self.fc.creator) self.assertEqual(scsummary['machine'], self.sc.machine) self.assertEqual(fcsummary['machine'], self.fc.machine) self.assertEqual(scsummary['attributes'], self.sc.attributes) self.assertEqual(fcsummary['attributes'], self.fc.attributes) self.assertEqual(fcsummary['unit'], self.fc.unit) self.assertEqual(scsummary['columns'][0], self.fc.id) from pyphant.core.H5FileHandler import im_id self.assertEqual(fcsummary['dimensions'], [im_id])
def testSaveLoad(self): handler = H5FH(self.fcFilename, 'w') with handler: handler.saveDataContainer(self.fc) fcLoaded = handler.loadDataContainer(self.fc.id) self.assertEqual(self.fc, fcLoaded)
def testReadOnlyFileNotFound(self): try: H5FH('', 'r') assert False except IOError: pass
def testReadOnly(self): handler = H5FH(self.roscFilename, 'r') with handler: scLoaded = handler.loadDataContainer(self.sc.id) self.assertEqual(self.sc, scLoaded)