def testCompoundTypeItem(self): dt = np.dtype([("temp", np.float32), ("pressure", np.float32), ("wind", np.int16)]) typeItem = h5type.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.assertEqual(tempFieldType['base'], 'H5T_IEEE_F32LE') typeItem = h5type.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.assertEqual(tempFieldType['class'], 'H5T_FLOAT') self.assertEqual(tempFieldType['base'], 'H5T_IEEE_F32LE')
def testBaseFloatTypeItem(self): dt = np.dtype('<f8') typeItem = h5type.getTypeItem(dt) self.assertEqual(typeItem['class'], 'H5T_FLOAT') self.assertEqual(typeItem['base'], 'H5T_IEEE_F64LE') typeItem = h5type.getTypeResponse(typeItem) # non-verbose format self.assertEqual(typeItem['class'], 'H5T_FLOAT') self.assertEqual(typeItem['base'], 'H5T_IEEE_F64LE')
def testBaseIntegerTypeItem(self): dt = np.dtype('<i1') typeItem = h5type.getTypeItem(dt) self.assertEqual(typeItem['class'], 'H5T_INTEGER') self.assertEqual(typeItem['base'], 'H5T_STD_I8LE') typeItem = h5type.getTypeResponse(typeItem) # non-verbose format self.assertEqual(typeItem['class'], 'H5T_INTEGER') self.assertEqual(typeItem['base'], 'H5T_STD_I8LE')