def testCompoundTypeItem(self): dt = np.dtype([("temp", np.float32), ("pressure", np.float32), ("wind", np.int16)]) typeItem = hdf5dtype.getTypeItem(dt) typeSize = hdf5dtype.getItemSize(typeItem) self.assertEqual(typeItem['class'], 'H5T_COMPOUND') self.assertTrue('fields' in typeItem) fields = typeItem['fields'] self.assertEqual(len(fields), 3) tempField = fields[0] self.assertEqual(tempField['name'], 'temp') self.assertTrue('type' in tempField) tempFieldType = tempField['type'] self.assertEqual(tempFieldType['class'], 'H5T_FLOAT') self.assertEqual(tempFieldType['base'], 'H5T_IEEE_F32LE') self.assertEqual(typeSize, 10) typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format typeSize = hdf5dtype.getItemSize(typeItem) self.assertEqual(typeItem['class'], 'H5T_COMPOUND') self.assertTrue('fields' in typeItem) fields = typeItem['fields'] self.assertEqual(len(fields), 3) tempField = fields[0] self.assertEqual(tempField['name'], 'temp') self.assertTrue('type' in tempField) tempFieldType = tempField['type'] self.assertEqual(tempFieldType['class'], 'H5T_FLOAT') self.assertEqual(tempFieldType['base'], 'H5T_IEEE_F32LE') self.assertEqual(typeSize, 10)
def testCompoundTypeItem(self): dt = np.dtype([("temp", np.float32), ("pressure", np.float32), ("wind", np.int16)]) typeItem = hdf5dtype.getTypeItem(dt) self.assertEqual(typeItem["class"], "H5T_COMPOUND") self.assertTrue("fields" in typeItem) fields = typeItem["fields"] self.assertEqual(len(fields), 3) tempField = fields[0] self.assertEqual(tempField["name"], "temp") self.assertTrue("type" in tempField) tempFieldType = tempField["type"] self.assertEqual(tempFieldType["class"], "H5T_FLOAT") self.failUnlessEqual(tempFieldType["size"], 4) self.failUnlessEqual(tempFieldType["base_size"], 4) self.failUnlessEqual(tempFieldType["order"], "H5T_ORDER_LE") self.failUnlessEqual(tempFieldType["base"], "H5T_IEEE_F32LE") typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.assertEqual(typeItem["class"], "H5T_COMPOUND") self.assertTrue("fields" in typeItem) fields = typeItem["fields"] self.assertEqual(len(fields), 3) tempField = fields[0] self.assertEqual(tempField["name"], "temp") self.assertTrue("type" in tempField) tempFieldType = tempField["type"] self.failUnlessEqual(tempFieldType["class"], "H5T_FLOAT") self.failUnlessEqual(tempFieldType["base"], "H5T_IEEE_F32LE")
def dumpDataset(self, uuid): response = {'id': uuid} item = self.db.getDatasetItemByUuid(uuid) response['alias'] = item['alias'] typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) shapeItem = item['shape'] response['shape'] = shapeItem if 'dims' in shapeItem and 'maxdims' in shapeItem: extensible = False dims = shapeItem['dims'] maxdims = shapeItem['maxdims'] for i in range(len(dims)): if dims[i] < maxdims[i]: extensible = True break # dump the fill value if extensible and 'fillvalue' in item: response['fillvalue'] = item['fillvalue'] attributes = self.dumpAttributes('datasets', uuid) response['attributes'] = attributes value = self.db.getDatasetValuesByUuid(uuid) response['value'] = value return response
def testCompoundTypeItem(self): dt = np.dtype([("temp", np.float32), ("pressure", np.float32), ("wind", np.int16)]) typeItem = hdf5dtype.getTypeItem(dt) self.assertEqual(typeItem['class'], 'H5T_COMPOUND') self.assertTrue('fields' in typeItem) fields = typeItem['fields'] self.assertEqual(len(fields), 3) tempField = fields[0] self.assertEqual(tempField['name'], 'temp') self.assertTrue('type' in tempField) tempFieldType = tempField['type'] self.assertEqual(tempFieldType['class'], 'H5T_FLOAT') self.failUnlessEqual(tempFieldType['size'], 4) self.failUnlessEqual(tempFieldType['base_size'], 4) self.failUnlessEqual(tempFieldType['order'], 'H5T_ORDER_LE') self.failUnlessEqual(tempFieldType['base'], 'H5T_IEEE_F32LE') typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.assertEqual(typeItem['class'], 'H5T_COMPOUND') self.assertTrue('fields' in typeItem) fields = typeItem['fields'] self.assertEqual(len(fields), 3) tempField = fields[0] self.assertEqual(tempField['name'], 'temp') self.assertTrue('type' in tempField) tempFieldType = tempField['type'] self.failUnlessEqual(tempFieldType['class'], 'H5T_FLOAT') self.failUnlessEqual(tempFieldType['base'], 'H5T_IEEE_F32LE')
def dumpDataset(self, uuid): response = { 'id': uuid } item = self.db.getDatasetItemByUuid(uuid) response['alias'] = item['alias'] typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) shapeItem = item['shape'] response['shape'] = shapeItem if 'dims' in shapeItem and 'maxdims' in shapeItem: extensible = False dims = shapeItem['dims'] maxdims = shapeItem['maxdims'] for i in range(len(dims)): if dims[i] < maxdims[i]: extensible = True break # dump the fill value if extensible and 'fillvalue' in item: response['fillvalue'] = item['fillvalue'] attributes = self.dumpAttributes('datasets', uuid) response['attributes'] = attributes value = self.db.getDatasetValuesByUuid(uuid) response['value'] = value return response
def testBaseFloatTypeItem(self): dt = np.dtype('<f8') typeItem = hdf5dtype.getTypeItem(dt) self.failUnlessEqual(typeItem['class'], 'H5T_FLOAT') self.failUnlessEqual(typeItem['base'], 'H5T_IEEE_F64LE') typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.failUnlessEqual(typeItem['class'], 'H5T_FLOAT') self.failUnlessEqual(typeItem['base'], 'H5T_IEEE_F64LE')
def dumpAttribute(self, col_name, uuid, attr_name): item = self.db.getAttributeItem(col_name, uuid, attr_name) response = {'name': attr_name} typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) response['shape'] = item['shape'] response['value'] = item['value'] return response
def testBaseIntegerTypeItem(self): dt = np.dtype('<i1') typeItem = hdf5dtype.getTypeItem(dt) self.assertEqual(typeItem['class'], 'H5T_INTEGER') self.assertEqual(typeItem['base'], 'H5T_STD_I8LE') typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.assertEqual(typeItem['class'], 'H5T_INTEGER') self.assertEqual(typeItem['base'], 'H5T_STD_I8LE')
def testBaseFloat16TypeItem(self): dt = np.dtype('<f2') typeItem = hdf5dtype.getTypeItem(dt) self.assertEqual(typeItem['class'], 'H5T_FLOAT') self.assertEqual(typeItem['base'], 'H5T_IEEE_F16LE') typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.assertEqual(typeItem['class'], 'H5T_FLOAT') self.assertEqual(typeItem['base'], 'H5T_IEEE_F16LE')
def dumpAttribute(self, col_name, uuid, attr_name): item = self.db.getAttributeItem(col_name, uuid, attr_name) response = { 'name': attr_name } typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) response['shape'] = item['shape'] response['value'] = item['value'] return response
def testBaseIntegerTypeItem(self): dt = np.dtype('<i1') typeItem = hdf5dtype.getTypeItem(dt) self.failUnlessEqual(typeItem['class'], 'H5T_INTEGER') self.failUnlessEqual(typeItem['base'], 'H5T_STD_I8LE') typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.failUnlessEqual(typeItem['class'], 'H5T_INTEGER') self.failUnlessEqual(typeItem['base'], 'H5T_STD_I8LE')
def dumpDatatype(self, uuid): response = {'id': uuid} item = self.db.getCommittedTypeItemByUuid(uuid) response['alias'] = item['alias'] typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) attributes = self.dumpAttributes('datatypes', uuid) response['attributes'] = attributes return response
def dumpDatatype(self, uuid): response = { 'id': uuid } item = self.db.getCommittedTypeItemByUuid(uuid) response['alias'] = item['alias'] typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) attributes = self.dumpAttributes('datatypes', uuid) response['attributes'] = attributes return response
def testBaseIntegerTypeItem(self): dt = np.dtype('<i1') typeItem = hdf5dtype.getTypeItem(dt) self.failUnlessEqual(typeItem['class'], 'H5T_INTEGER') self.failUnlessEqual(typeItem['size'], 1) self.failUnlessEqual(typeItem['base_size'], 1) self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_LE') self.failUnlessEqual(typeItem['base'], 'H5T_STD_I8LE') typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.failUnlessEqual(typeItem['class'], 'H5T_INTEGER') self.failUnlessEqual(typeItem['base'], 'H5T_STD_I8LE')
def testBaseIntegerTypeItem(self): dt = np.dtype("<i1") typeItem = hdf5dtype.getTypeItem(dt) self.failUnlessEqual(typeItem["class"], "H5T_INTEGER") self.failUnlessEqual(typeItem["size"], 1) self.failUnlessEqual(typeItem["base_size"], 1) self.failUnlessEqual(typeItem["order"], "H5T_ORDER_LE") self.failUnlessEqual(typeItem["base"], "H5T_STD_I8LE") typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.failUnlessEqual(typeItem["class"], "H5T_INTEGER") self.failUnlessEqual(typeItem["base"], "H5T_STD_I8LE")
def testBaseFloatTypeItem(self): dt = np.dtype("<f8") typeItem = hdf5dtype.getTypeItem(dt) self.failUnlessEqual(typeItem["class"], "H5T_FLOAT") self.failUnlessEqual(typeItem["size"], 8) self.failUnlessEqual(typeItem["base_size"], 8) self.failUnlessEqual(typeItem["order"], "H5T_ORDER_LE") self.failUnlessEqual(typeItem["base"], "H5T_IEEE_F64LE") typeItem = hdf5dtype.getTypeResponse(typeItem) # non-verbose format self.failUnlessEqual(typeItem["class"], "H5T_FLOAT") self.failUnlessEqual(typeItem["base"], "H5T_IEEE_F64LE")
def dumpAttribute(self, col_name, uuid, attr_name): self.log.info("dumpAttribute: [" + attr_name + "]") item = self.db.getAttributeItem(col_name, uuid, attr_name) response = { 'name': attr_name } typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) response['shape'] = item['shape'] if not self.options.D: if 'value' not in item: self.log.warning("no value key in attribute: " + attr_name) else: response['value'] = item['value'] # dump values unless header -D was passed return response
def dumpDataset(self, uuid): response = { } self.log.info("dumpDataset: " + uuid) item = self.db.getDatasetItemByUuid(uuid) if 'alias' in item: alias = item['alias'] if alias: self.log.info("dumpDataset alias: [" + alias[0] + "]") response['alias'] = item['alias'] typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) shapeItem = item['shape'] shape_rsp = {} num_elements = 1 shape_rsp['class'] = shapeItem['class'] if 'dims' in shapeItem: shape_rsp['dims'] = shapeItem['dims'] for dim in shapeItem['dims']: num_elements *= dim if 'maxdims' in shapeItem: maxdims = [] for dim in shapeItem['maxdims']: if dim == 0: maxdims.append('H5S_UNLIMITED') else: maxdims.append(dim) shape_rsp['maxdims'] = maxdims response['shape'] = shape_rsp if 'creationProperties' in item: response['creationProperties'] = item['creationProperties'] attributes = self.dumpAttributes('datasets', uuid) if attributes: response['attributes'] = attributes if not (self.options.D or self.options.d): if num_elements > 0: value = self.db.getDatasetValuesByUuid(uuid) response['value'] = value # dump values unless header flag was passed else: response['value'] = [] # empty list return response
def dumpDataset(self, uuid): response = {} self.log.info("dumpDataset: " + uuid) item = self.db.getDatasetItemByUuid(uuid) if 'alias' in item: alias = item['alias'] if alias: self.log.info("dumpDataset alias: [" + alias[0] + "]") response['alias'] = item['alias'] typeItem = item['type'] response['type'] = hdf5dtype.getTypeResponse(typeItem) shapeItem = item['shape'] shape_rsp = {} num_elements = 1 shape_rsp['class'] = shapeItem['class'] if 'dims' in shapeItem: shape_rsp['dims'] = shapeItem['dims'] for dim in shapeItem['dims']: num_elements *= dim if 'maxdims' in shapeItem: maxdims = [] for dim in shapeItem['maxdims']: if dim == 0: maxdims.append('H5S_UNLIMITED') else: maxdims.append(dim) shape_rsp['maxdims'] = maxdims response['shape'] = shape_rsp if 'creationProperties' in item: response['creationProperties'] = item['creationProperties'] attributes = self.dumpAttributes('datasets', uuid) if attributes: response['attributes'] = attributes if not (self.options.D or self.options.d): if num_elements > 0: value = self.db.getDatasetValuesByUuid(uuid) response[ 'value'] = value # dump values unless header flag was passed else: response['value'] = [] # empty list return response