55
66
77import logging
8+ from distutils .version import LooseVersion
89import pickle
910import numpy as np
1011import quantities as pq
2324from neo .core .baseneo import MergeError
2425
2526logger = logging .getLogger ('Neo' )
26-
27+ min_h5py_version = LooseVersion ( '2.6.0' )
2728
2829def disjoint_groups (groups ):
2930 """`groups` should be a list of sets"""
@@ -55,6 +56,10 @@ class NeoHdf5IO(BaseIO):
5556 def __init__ (self , filename ):
5657 if not HAVE_H5PY :
5758 raise ImportError ("h5py is not available" )
59+ if HAVE_H5PY :
60+ if LooseVersion (h5py .__version__ ) < min_h5py_version :
61+ raise ImportError ('h5py version {} is too old. Minimal required version is {}'
62+ '' .format (h5py .__version__ , min_h5py_version ))
5863 BaseIO .__init__ (self , filename = filename )
5964 self ._data = h5py .File (filename , 'r' )
6065 self .object_refs = {}
@@ -213,7 +218,7 @@ def _read_epocharray(self, node, parent):
213218 attributes = self ._get_standard_attributes (node )
214219 times = self ._get_quantity (node ["times" ])
215220 durations = self ._get_quantity (node ["durations" ])
216- labels = node ["labels" ]. value .astype ('U' )
221+ labels = node ["labels" ][()] .astype ('U' )
217222 epoch = Epoch (times = times , durations = durations , labels = labels , ** attributes )
218223 epoch .segment = parent
219224 return epoch
@@ -224,7 +229,7 @@ def _read_epoch(self, node, parent):
224229 def _read_eventarray (self , node , parent ):
225230 attributes = self ._get_standard_attributes (node )
226231 times = self ._get_quantity (node ["times" ])
227- labels = node ["labels" ]. value .astype ('U' )
232+ labels = node ["labels" ][()] .astype ('U' )
228233 event = Event (times = times , labels = labels , ** attributes )
229234 event .segment = parent
230235 return event
@@ -235,8 +240,8 @@ def _read_event(self, node, parent):
235240 def _read_recordingchannelgroup (self , node , parent ):
236241 # todo: handle Units
237242 attributes = self ._get_standard_attributes (node )
238- channel_indexes = node ["channel_indexes" ]. value
239- channel_names = node ["channel_names" ]. value
243+ channel_indexes = node ["channel_indexes" ][()]
244+ channel_names = node ["channel_names" ][()]
240245
241246 if channel_indexes .size :
242247 if len (node ['recordingchannels' ]):
0 commit comments