示例#1
0
 def testVlenDataItem(self):
     dt = special_dtype(vlen=np.dtype('int32'))
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_VLEN')
     self.failUnlessEqual(typeItem['size'], 'H5T_VARIABLE')
     baseItem = typeItem['base']
     self.failUnlessEqual(baseItem['base'], 'H5T_STD_I32LE')
示例#2
0
 def testVlenDataItem(self):
     dt = special_dtype(vlen=np.dtype('int32'))
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_VLEN')
     self.failUnlessEqual(typeItem['size'], 'H5T_VARIABLE')
     baseItem = typeItem['base']
     self.failUnlessEqual(baseItem['base'], 'H5T_STD_I32LE')
示例#3
0
 def testBaseStringTypeItem(self):
     dt = np.dtype('S3')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.assertEqual(typeItem['class'], 'H5T_STRING')
     self.assertEqual(typeItem['length'], 3)
     self.assertEqual(typeItem['strPad'], 'H5T_STR_NULLPAD')
     self.assertEqual(typeItem['charSet'], 'H5T_CSET_ASCII')
示例#4
0
 def testBaseArrayTypeItem(self):
     dt = np.dtype('(2,2)<int32')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_ARRAY')
     baseItem = typeItem['base']
     self.failUnlessEqual(baseItem['class'], 'H5T_INTEGER')
     self.failUnlessEqual(baseItem['base'], 'H5T_STD_I32LE')
示例#5
0
 def testBaseVLenUnicodeTypeItem(self):
     dt = special_dtype(vlen=six.text_type)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['length'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['strPad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['charSet'], 'H5T_CSET_UTF8')
示例#6
0
    def testCompoundArrayVlenStringTypeItem(self):
        dt_vlen = special_dtype(vlen=bytes)
        dt_arr = np.dtype((dt_vlen, (4, )))
        dt_compound = np.dtype([('VALUE1', np.float64), ('VALUE2', np.int64),
                                ('VALUE3', dt_arr)])
        typeItem = hdf5dtype.getTypeItem(dt_compound)

        typeSize = hdf5dtype.getItemSize(typeItem)
        self.assertEqual(typeSize, 'H5T_VARIABLE')
        self.assertEqual(typeItem['class'], 'H5T_COMPOUND')
        fields = typeItem['fields']
        field_a = fields[0]
        self.assertEqual(field_a['name'], 'VALUE1')
        field_a_type = field_a['type']
        self.assertEqual(field_a_type['class'], 'H5T_FLOAT')
        self.assertEqual(field_a_type['base'], 'H5T_IEEE_F64LE')
        field_b = fields[1]
        self.assertEqual(field_b['name'], 'VALUE2')
        field_b_type = field_b['type']
        self.assertEqual(field_b_type['class'], 'H5T_INTEGER')
        self.assertEqual(field_b_type['base'], 'H5T_STD_I64LE')
        field_c = fields[2]
        field_c_type = field_c['type']

        self.assertEqual(field_c_type['class'], 'H5T_ARRAY')
        self.assertEqual(field_c_type['dims'], (4, ))
        field_c_base_type = field_c_type['base']
        self.assertEqual(field_c_base_type['class'], 'H5T_STRING')
        self.assertEqual(field_c_base_type['length'], 'H5T_VARIABLE')
        self.assertEqual(field_c_base_type['charSet'], 'H5T_CSET_ASCII')
示例#7
0
 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')  
示例#8
0
 def testOpaqueTypeItem(self):
     dt = np.dtype('V200')
     typeItem = hdf5dtype.getTypeItem(dt)
     typeSize = hdf5dtype.getItemSize(typeItem)
     self.assertEqual(typeItem['class'], 'H5T_OPAQUE')
     self.assertTrue('base' not in typeItem)
     self.assertEqual(typeSize, 200)
示例#9
0
    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")
示例#10
0
 def testBaseArrayTypeItem(self):
     dt = np.dtype('(2,2)<int32')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_ARRAY')
     baseItem = typeItem['base']
     self.failUnlessEqual(baseItem['class'], 'H5T_INTEGER')
     self.failUnlessEqual(baseItem['base'], 'H5T_STD_I32LE')
示例#11
0
 def testBaseVLenUnicodeTypeItem(self):
     dt = special_dtype(vlen=six.text_type)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['length'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['strPad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['charSet'], 'H5T_CSET_UTF8')
示例#12
0
    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)
示例#13
0
 def testBaseVLenAsciiTypeItem(self):
     dt = special_dtype(vlen=six.binary_type)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['length'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['strPad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['charSet'], 'H5T_CSET_ASCII')
示例#14
0
 def testBaseStringUTFTypeItem(self):
     dt = np.dtype('U3')
     try:
         typeItem = hdf5dtype.getTypeItem(dt)
         self.assertTrue(False)  # expected exception
     except TypeError:
         pass # expected
示例#15
0
 def testBaseStringTypeItem(self):
     dt = np.dtype('S3')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['length'], 3)
     self.failUnlessEqual(typeItem['strPad'], 'H5T_STR_NULLPAD')
     self.failUnlessEqual(typeItem['charSet'], 'H5T_CSET_ASCII')
示例#16
0
 def testBaseVLenAsciiTypeItem(self):
     dt = special_dtype(vlen=six.binary_type)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['length'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['strPad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['charSet'], 'H5T_CSET_ASCII')
示例#17
0
 def testBaseStringUTFTypeItem(self):
     dt = np.dtype('U3')
     try:
         typeItem = hdf5dtype.getTypeItem(dt)
         self.assertTrue(False)  # expected exception
     except TypeError:
         pass  # expected
示例#18
0
 def testOpaqueTypeItem(self):
     dt = np.dtype("V200")
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem["class"], "H5T_OPAQUE")
     self.failUnlessEqual(typeItem["size"], 200)
     self.failUnlessEqual(typeItem["base_size"], 200)
     self.failUnlessEqual(typeItem["order"], "H5T_ORDER_NONE")
     self.assertTrue("base" not in typeItem)
示例#19
0
 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')
示例#20
0
 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')
示例#21
0
 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')
示例#22
0
 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')
示例#23
0
 def testOpaqueTypeItem(self):
     dt = np.dtype('V200')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_OPAQUE')
     self.failUnlessEqual(typeItem['size'], 200)
     self.failUnlessEqual(typeItem['base_size'], 200)
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.assertTrue('base' not in typeItem)
示例#24
0
 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')
示例#25
0
 def testOpaqueTypeItem(self):
     dt = np.dtype('V200')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_OPAQUE')
     self.failUnlessEqual(typeItem['size'], 200)
     self.failUnlessEqual(typeItem['base_size'], 200)
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.assertTrue('base' not in typeItem)
示例#26
0
 def testBaseVLenUnicodeTypeItem(self):
     dt = special_dtype(vlen=unicode)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem["class"], "H5T_STRING")
     self.failUnlessEqual(typeItem["base_size"], 8)
     self.failUnlessEqual(typeItem["length"], "H5T_VARIABLE")
     self.failUnlessEqual(typeItem["order"], "H5T_ORDER_NONE")
     self.failUnlessEqual(typeItem["strPad"], "H5T_STR_NULLTERM")
     self.failUnlessEqual(typeItem["charSet"], "H5T_CSET_UTF8")
示例#27
0
 def testBaseVLenUnicodeTypeItem(self):
     dt = special_dtype(vlen=str)
     typeItem = hdf5dtype.getTypeItem(dt)
     typeSize = hdf5dtype.getItemSize(typeItem)
     self.assertEqual(typeItem['class'], 'H5T_STRING')
     self.assertEqual(typeItem['length'], 'H5T_VARIABLE')
     self.assertEqual(typeItem['strPad'], 'H5T_STR_NULLTERM')
     self.assertEqual(typeItem['charSet'], 'H5T_CSET_UTF8')
     self.assertEqual(typeSize, 'H5T_VARIABLE')
示例#28
0
 def testBaseVLenUnicodeTypeItem(self):
     dt = special_dtype(vlen=unicode)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['base_size'], 8)
     self.failUnlessEqual(typeItem['strsize'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.failUnlessEqual(typeItem['strpad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['cset'], 'H5T_CSET_UTF8')
示例#29
0
 def testVlenDataItem(self):
     dt = special_dtype(vlen=np.dtype("int32"))
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem["class"], "H5T_VLEN")
     self.failUnlessEqual(typeItem["size"], "H5T_VARIABLE")
     baseItem = typeItem["base"]
     self.failUnlessEqual(baseItem["size"], 4)
     self.failUnlessEqual(baseItem["order"], "H5T_ORDER_LE")
     self.failUnlessEqual(baseItem["base"], "H5T_STD_I32LE")
示例#30
0
 def testBaseVLenUnicodeTypeItem(self):
     dt = special_dtype(vlen=unicode)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['base_size'], 8)
     self.failUnlessEqual(typeItem['strsize'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.failUnlessEqual(typeItem['strpad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['cset'], 'H5T_CSET_UTF8')
示例#31
0
 def testBaseVLenAsciiTypeItem(self):
     dt = special_dtype(vlen=str)
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['base_size'], 8)
     self.failUnlessEqual(typeItem['length'], 'H5T_VARIABLE')
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.failUnlessEqual(typeItem['strPad'], 'H5T_STR_NULLTERM')
     self.failUnlessEqual(typeItem['charSet'], 'H5T_CSET_ASCII')
示例#32
0
 def testBaseArrayTypeItem(self):
     dt = np.dtype('(2,2)<int32')
     typeItem = hdf5dtype.getTypeItem(dt)
     typeSize = hdf5dtype.getItemSize(typeItem)
     self.assertEqual(typeItem['class'], 'H5T_ARRAY')
     baseItem = typeItem['base']
     self.assertEqual(baseItem['class'], 'H5T_INTEGER')
     self.assertEqual(baseItem['base'], 'H5T_STD_I32LE')
     self.assertEqual(typeSize, 16)
示例#33
0
 def testObjReferenceTypeItem(self):
     dt = special_dtype(ref=Reference)
     typeItem = hdf5dtype.getTypeItem(dt)
     typeSize = hdf5dtype.getItemSize(typeItem)
     self.assertEqual(typeItem['class'], 'H5T_REFERENCE')
     self.assertEqual(typeItem['base'], 'H5T_STD_REF_OBJ')
     # length of obj id, e.g.:
     # g-b2c9a750-a557-11e7-ab09-0242ac110009
     self.assertEqual(typeSize, 48)
示例#34
0
 def testBaseStringTypeItem(self):
     dt = np.dtype('S3')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['size'], 3)
     self.failUnlessEqual(typeItem['base_size'], 3)
     self.failUnlessEqual(typeItem['strsize'], 3)
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.failUnlessEqual(typeItem['strpad'], 'H5T_STR_NULLPAD')
     self.failUnlessEqual(typeItem['cset'], 'H5T_CSET_ASCII')
示例#35
0
 def testBaseEnumTypeItem(self):
     mapping = {'RED': 0, 'GREEN': 1, 'BLUE': 2}
     dt = special_dtype(enum=(np.int8, mapping))
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_ENUM')
     baseItem = typeItem['base']
     self.failUnlessEqual(baseItem['class'], 'H5T_INTEGER')
     self.failUnlessEqual(baseItem['base'], 'H5T_STD_I8LE')
     self.assertTrue('mapping' in typeItem)
     self.failUnlessEqual(typeItem['mapping']['GREEN'], 1)
示例#36
0
 def testBaseStringTypeItem(self):
     dt = np.dtype("S3")
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem["class"], "H5T_STRING")
     self.failUnlessEqual(typeItem["size"], 3)
     self.failUnlessEqual(typeItem["base_size"], 3)
     self.failUnlessEqual(typeItem["length"], 3)
     self.failUnlessEqual(typeItem["order"], "H5T_ORDER_NONE")
     self.failUnlessEqual(typeItem["strPad"], "H5T_STR_NULLPAD")
     self.failUnlessEqual(typeItem["charSet"], "H5T_CSET_ASCII")
示例#37
0
 def testBaseStringTypeItem(self):
     dt = np.dtype('S3')
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_STRING')
     self.failUnlessEqual(typeItem['size'], 3)
     self.failUnlessEqual(typeItem['base_size'], 3)
     self.failUnlessEqual(typeItem['strsize'], 3)
     self.failUnlessEqual(typeItem['order'], 'H5T_ORDER_NONE')
     self.failUnlessEqual(typeItem['strpad'], 'H5T_STR_NULLPAD')
     self.failUnlessEqual(typeItem['cset'], 'H5T_CSET_ASCII')
示例#38
0
 def testBaseArrayTypeItem(self):
     dt = np.dtype("(2,2)<int32")
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem["class"], "H5T_ARRAY")
     baseItem = typeItem["base"]
     self.failUnlessEqual(baseItem["class"], "H5T_INTEGER")
     self.failUnlessEqual(baseItem["size"], 16)
     self.failUnlessEqual(baseItem["base_size"], 4)
     self.failUnlessEqual(baseItem["order"], "H5T_ORDER_LE")
     self.failUnlessEqual(baseItem["base"], "H5T_STD_I32LE")
示例#39
0
 def testBaseEnumTypeItem(self):
     mapping = {'RED': 0, 'GREEN': 1, 'BLUE': 2}
     dt = special_dtype(enum=(np.int8, mapping))
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_ENUM')
     baseItem = typeItem['base']
     self.failUnlessEqual(baseItem['class'], 'H5T_INTEGER')
     self.failUnlessEqual(baseItem['base'], 'H5T_STD_I8LE')
     self.assertTrue('mapping' in typeItem)
     self.failUnlessEqual(typeItem['mapping']['GREEN'], 1)
示例#40
0
 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')
示例#41
0
 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")
示例#42
0
 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")
示例#43
0
 def testBaseEnumTypeItem(self):
     mapping = {"RED": 0, "GREEN": 1, "BLUE": 2}
     dt = special_dtype(enum=(np.int8, mapping))
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem["class"], "H5T_ENUM")
     baseItem = typeItem["base"]
     self.failUnlessEqual(baseItem["class"], "H5T_INTEGER")
     self.failUnlessEqual(baseItem["size"], 1)
     self.failUnlessEqual(baseItem["base_size"], 1)
     self.failUnlessEqual(baseItem["order"], "H5T_ORDER_LE")
     self.failUnlessEqual(baseItem["base"], "H5T_STD_I8LE")
     self.assertTrue("mapping" in typeItem)
     self.failUnlessEqual(typeItem["mapping"]["GREEN"], 1)
示例#44
0
 def testBaseBoolTypeItem(self):
     typeItem = hdf5dtype.getTypeItem(np.dtype('bool'))
     typeSize = hdf5dtype.getItemSize(typeItem)
     self.assertEqual(typeItem['class'], 'H5T_ENUM')
     baseItem = typeItem['base']
     self.assertEqual(baseItem['class'], 'H5T_INTEGER')
     self.assertEqual(baseItem['base'], 'H5T_STD_I8LE')
     self.assertTrue('mapping' in typeItem)
     mapping = typeItem['mapping']
     self.assertEqual(len(mapping), 2)
     self.assertEqual(mapping['FALSE'], 0)
     self.assertEqual(mapping['TRUE'], 1)
     self.assertEqual(typeSize, 1)
示例#45
0
    def testEnumArrayTypeItem(self):
        mapping = {'RED': 0, 'GREEN': 1, 'BLUE': 2}
        dt_enum = special_dtype(enum=(np.int8, mapping))
        typeItem = hdf5dtype.getTypeItem(dt_enum)
        dt_array = np.dtype('(2,3)' + dt_enum.str,
                            metadata=dict(dt_enum.metadata))

        typeItem = hdf5dtype.getTypeItem(dt_array)

        self.assertEqual(typeItem['class'], 'H5T_ARRAY')
        self.assertTrue("dims" in typeItem)
        self.assertEqual(typeItem["dims"], (2, 3))
        baseItem = typeItem['base']
        self.assertEqual(baseItem['class'], 'H5T_ENUM')
        self.assertTrue('mapping' in baseItem)
        self.assertEqual(baseItem['mapping']['GREEN'], 1)
        self.assertTrue("base" in baseItem)
        basePrim = baseItem["base"]
        self.assertEqual(basePrim["class"], 'H5T_INTEGER')
        self.assertEqual(basePrim['base'], 'H5T_STD_I8LE')
        typeSize = hdf5dtype.getItemSize(typeItem)
        self.assertEqual(typeSize,
                         6)  # one-byte for base enum type * shape of (2,3)
示例#46
0
 def testCompoundArrayTypeItem(self):
     dt = np.dtype([('a', '<i1'), ('b', 'S1', (10,))])
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_COMPOUND')
     fields = typeItem['fields']
     field_a = fields[0]
     self.failUnlessEqual(field_a['name'], 'a')
     field_a_type = field_a['type']
     self.failUnlessEqual(field_a_type['class'], 'H5T_INTEGER')
     self.failUnlessEqual(field_a_type['base'], 'H5T_STD_I8LE')
     field_b = fields[1]
     self.failUnlessEqual(field_b['name'], 'b')
     field_b_type = field_b['type']
     self.failUnlessEqual(field_b_type['class'], 'H5T_ARRAY')
     self.failUnlessEqual(field_b_type['dims'], (10,))
     field_b_basetype = field_b_type['base']
     self.failUnlessEqual(field_b_basetype['class'], 'H5T_STRING')
示例#47
0
 def testCompoundArrayTypeItem(self):
     dt = np.dtype([('a', '<i1'), ('b', 'S1', (10, ))])
     typeItem = hdf5dtype.getTypeItem(dt)
     self.failUnlessEqual(typeItem['class'], 'H5T_COMPOUND')
     fields = typeItem['fields']
     field_a = fields[0]
     self.failUnlessEqual(field_a['name'], 'a')
     field_a_type = field_a['type']
     self.failUnlessEqual(field_a_type['class'], 'H5T_INTEGER')
     self.failUnlessEqual(field_a_type['base'], 'H5T_STD_I8LE')
     field_b = fields[1]
     self.failUnlessEqual(field_b['name'], 'b')
     field_b_type = field_b['type']
     self.failUnlessEqual(field_b_type['class'], 'H5T_ARRAY')
     self.failUnlessEqual(field_b_type['dims'], (10, ))
     field_b_basetype = field_b_type['base']
     self.failUnlessEqual(field_b_basetype['class'], 'H5T_STRING')
示例#48
0
    def testCompoundofCompoundTypeItem(self):
        dt1 = np.dtype([("x", np.float32), ("y", np.float32)])
        dt2 = np.dtype([("a", np.float32), ("b", np.float32),
                        ("c", np.float32)])
        dt = np.dtype([("field1", dt1), ("field2", dt2)])
        typeItem = hdf5dtype.getTypeItem(dt)

        typeSize = hdf5dtype.getItemSize(typeItem)
        self.assertEqual(typeSize, 20)
        self.assertEqual(typeItem['class'], 'H5T_COMPOUND')
        self.assertTrue('fields' in typeItem)
        fields = typeItem['fields']
        self.assertEqual(len(fields), 2)
        field1 = fields[0]

        self.assertEqual(field1['name'], "field1")
        field1_type = field1['type']
        self.assertEqual(field1_type['class'], 'H5T_COMPOUND')
        field2 = fields[1]

        self.assertEqual(field2['name'], "field2")
        field2_type = field2['type']
        self.assertEqual(field2_type['class'], 'H5T_COMPOUND')
示例#49
0
 def testRegionReferenceTypeItem(self):
     dt = special_dtype(ref=RegionReference)
     typeItem = hdf5dtype.getTypeItem(dt)
     typeSize = hdf5dtype.getItemSize(typeItem)
     self.assertEqual(typeItem['class'], 'H5T_REFERENCE')