def _assertWriteElement(self, filePrefix, contents, dataType, dataTypeDim, maxNumEdges, maxStrLens, \ assertContents, assertDataType, assertDataTypeDim, assertElementDim): s = Setup(filePrefix, len(assertContents), assertDataType, assertDataTypeDim, assertElementDim) valDataType = dataType if filePrefix == 'val' else 'float64' valDim = dataTypeDim if filePrefix == 'val' else 1 weightDataType = dataType if filePrefix == 'weights' else 'float64' weightDim = dataTypeDim if filePrefix == 'weights' else 1 geList = GEList() memberName = '_' + filePrefix + 'List' if hasattr(geList, memberName): geList.__dict__[memberName] = contents else: geList._extraList = [{filePrefix: x} for x in contents] #print s.fn, s.path, s.filePrefix, len(geList), valDataType, valDim, weightDataType, weightDim, maxNumEdges, maxStrLens of = OutputFile(s.path, s.filePrefix, len(assertContents), valDataType, valDim, weightDataType, weightDim, maxNumEdges, maxStrLens) for ge in geList: of.writeElement(ge) of.close() self.assertTrue(os.path.exists(s.fn)) fileContents = [el for el in memmap(s.fn, dtype=s.dataType, shape=s.shape, mode='r')] self.assertListsOrDicts(assertContents, fileContents) return s