77
88import h5py
99import yaml
10- from numpy import string_
10+ from numpy import str_
1111
1212TYPE = "_type_"
1313
@@ -45,7 +45,7 @@ def unpack_dataset(item):
4545
4646 """
4747 value = item [()]
48- type_id = item .attrs .get (TYPE , string_ ()).astype (str )
48+ type_id = item .attrs .get (TYPE , str_ ()).astype (str )
4949 if type_id == "datetime" :
5050 if hasattr (value , "__iter__" ):
5151 value = [datetime .fromtimestamp (ts ) for ts in value ]
@@ -62,7 +62,7 @@ def unpack_dataset(item):
6262 value = tuple (value )
6363
6464 elif type_id == "str" :
65- value = string_ (value ).astype (str )
65+ value = str_ (value ).astype (str )
6666
6767 return value
6868
@@ -181,15 +181,15 @@ def pack_dataset(hdfobject, key, value):
181181 attr_data = None
182182
183183 if attr_data :
184- ds .attrs .create (name = TYPE , data = string_ (attr_data ))
184+ ds .attrs .create (name = TYPE , data = str_ (attr_data ))
185185
186186 except (TypeError , ValueError ):
187187 # Obviously the data was not serializable. To give it
188188 # a last try; serialize it to yaml
189189 # and save it to the hdf file:
190- ds = hdfobject .create_dataset (name = key , data = string_ (yaml .safe_dump (value )))
190+ ds = hdfobject .create_dataset (name = key , data = str_ (yaml .safe_dump (value )))
191191
192- ds .attrs .create (name = TYPE , data = string_ ("yaml" ))
192+ ds .attrs .create (name = TYPE , data = str_ ("yaml" ))
193193 # if this fails again, restructure your data!
194194
195195
0 commit comments