@@ -730,8 +730,35 @@ def testReadFixedStringDataset(self):
730
730
self .assertEqual (item_type ['strPad' ], 'H5T_STR_NULLPAD' )
731
731
self .assertEqual (item_type ['charSet' ], 'H5T_CSET_ASCII' )
732
732
self .assertEqual (item_type ['length' ], 7 )
733
- row = db .getDatasetValuesByUuid (dset_uuid , (slice (0 , 1 ),))
734
- self .assertEqual (row , ['Parting' ])
733
+ row = db .getDatasetValuesByUuid (dset_uuid )
734
+ self .assertEqual (row , ["Parting" , "is such" , "sweet" , "sorrow." ])
735
+ row = db .getDatasetValuesByUuid (dset_uuid , (slice (0 ,1 ),))
736
+ self .assertEqual (row , ["Parting" ,])
737
+ row = db .getDatasetValuesByUuid (dset_uuid , (slice (2 ,3 ),))
738
+ self .assertEqual (row , ["sweet" ,])
739
+
740
+ def testReadFixedStringDatasetBinary (self ):
741
+ item = None
742
+ filepath = getFile ('fixed_string_dset.h5' , 'fixed_string_dset.h5' )
743
+ with Hdf5db (filepath , app_logger = self .log ) as db :
744
+ dset_uuid = db .getUUIDByPath ('/DS1' )
745
+ item = db .getDatasetItemByUuid (dset_uuid )
746
+ shape = item ['shape' ]
747
+ self .assertEqual (shape ['class' ], 'H5S_SIMPLE' )
748
+ dims = shape ['dims' ]
749
+ self .assertEqual (len (dims ), 1 )
750
+ self .assertEqual (dims [0 ], 4 )
751
+ item_type = item ['type' ]
752
+ self .assertEqual (item_type ['class' ], 'H5T_STRING' )
753
+ self .assertEqual (item_type ['strPad' ], 'H5T_STR_NULLPAD' )
754
+ self .assertEqual (item_type ['charSet' ], 'H5T_CSET_ASCII' )
755
+ self .assertEqual (item_type ['length' ], 7 )
756
+ row = db .getDatasetValuesByUuid (dset_uuid , format = "binary" )
757
+ self .assertEqual (row , b"Partingis suchsweet\x00 \x00 sorrow." )
758
+ row = db .getDatasetValuesByUuid (dset_uuid , (slice (0 ,1 ),), format = "binary" )
759
+ self .assertEqual (row , b"Parting" )
760
+ row = db .getDatasetValuesByUuid (dset_uuid , (slice (2 ,3 ),), format = "binary" )
761
+ self .assertEqual (row , b"sweet\x00 \x00 " )
735
762
736
763
737
764
def testWriteVlenUnicodeAttribute (self ):
@@ -1035,13 +1062,17 @@ def testBytesArrayToList(self):
1035
1062
val = db .bytesArrayToList (b'Hello' )
1036
1063
self .assertTrue (type (val ) is str )
1037
1064
val = db .bytesArrayToList ([b'Hello' ,])
1065
+ self .assertEqual (len (val ), 1 )
1038
1066
self .assertTrue (type (val [0 ]) is str )
1067
+ self .assertEqual (val [0 ], 'Hello' )
1039
1068
1040
1069
import numpy as np
1041
1070
1042
1071
data = np .array ([b'Hello' ])
1043
1072
val = db .bytesArrayToList (data )
1073
+ self .assertEqual (len (val ), 1 )
1044
1074
self .assertTrue (type (val [0 ]) is str )
1075
+ self .assertEqual (val [0 ], 'Hello' )
1045
1076
1046
1077
1047
1078
def testGetDataValue (self ):
0 commit comments