@@ -475,6 +475,21 @@ def createBaseDataType(typeItem):
475
475
dtRet = special_dtype (ref = RegionReference )
476
476
else :
477
477
raise TypeError ("Invalid base type for reference type" )
478
+ elif typeClass == 'H5T_ENUM' :
479
+ if 'base' not in typeItem :
480
+ raise KeyError ("Expected 'base' to be provided for enum type" )
481
+ base_json = typeItem ["base" ]
482
+ if 'class' not in base_json :
483
+ raise KeyError ("Expected class field in base type" )
484
+ if base_json ['class' ] != 'H5T_INTEGER' :
485
+ raise TypeError ("Only integer base types can be used with enum type" )
486
+ if 'mapping' not in typeItem :
487
+ raise KeyError ("'mapping' not provided for enum type" )
488
+ mapping = typeItem ["mapping" ]
489
+ if len (mapping ) == 0 :
490
+ raise KeyError ("empty enum map" )
491
+ dt = createBaseDataType (base_json )
492
+ dtRet = special_dtype (enum = (dt , mapping ))
478
493
479
494
else :
480
495
raise TypeError ("Invalid type class" )
@@ -534,21 +549,6 @@ def createDataType(typeItem):
534
549
subtypes .append ((field ['name' ], dt )) # append tuple
535
550
536
551
dtRet = np .dtype (subtypes )
537
- elif typeClass == 'H5T_ENUM' :
538
- if 'base' not in typeItem :
539
- raise KeyError ("Expected 'base' to be provided for enum type" )
540
- base_json = typeItem ["base" ]
541
- if 'class' not in base_json :
542
- raise KeyError ("Expected class field in base type" )
543
- if base_json ['class' ] != 'H5T_INTEGER' :
544
- raise TypeError ("Only integer base types can be used with enum type" )
545
- if 'mapping' not in typeItem :
546
- raise KeyError ("'mapping' not provided for enum type" )
547
- mapping = typeItem ["mapping" ]
548
- if len (mapping ) == 0 :
549
- raise KeyError ("empty enum map" )
550
- dt = createBaseDataType (base_json )
551
- dtRet = special_dtype (enum = (dt , mapping ))
552
552
553
553
else :
554
554
dtRet = createBaseDataType (typeItem ) # create non-compound dt
0 commit comments