def testCreateCompoundType(self): typeItem = { 'class': 'H5T_COMPOUND', 'fields': [{ 'name': 'temp', 'type': 'H5T_IEEE_F32LE' }, { 'name': 'pressure', 'type': 'H5T_IEEE_F32LE' }, { 'name': 'location', 'type': { 'length': 'H5T_VARIABLE', 'charSet': 'H5T_CSET_ASCII', 'class': 'H5T_STRING', 'strPad': 'H5T_STR_NULLTERM' } }, { 'name': 'wind', 'type': 'H5T_STD_I16LE' }] } dt = h5type.createDataType(typeItem) self.assertEqual(dt.name, 'void144') self.assertEqual(dt.kind, 'V') self.assertEqual(len(dt.fields), 4) dtLocation = dt[2] self.assertEqual(dtLocation.name, 'object') self.assertEqual(dtLocation.kind, 'O') self.assertEqual(check_dtype(vlen=dtLocation), bytes)
def testRefType(self): # todo - special_dtype not implemented dt = special_dtype(ref=Reference) self.assertEqual(dt.kind, 'S') self.assertTrue(dt.metadata['ref'] is Reference) reftype = check_dtype(ref=dt) self.assertTrue(reftype is Reference)
def testCreateVLenUTF8Type(self): typeItem = { 'class': 'H5T_STRING', 'charSet': 'H5T_CSET_UTF8', 'length': 'H5T_VARIABLE' } dt = h5type.createDataType(typeItem) self.assertEqual(dt.name, 'object') self.assertEqual(dt.kind, 'O') self.assertEqual(check_dtype(vlen=dt), str)