Minor fix - check for ragged array length when exporting to hdf5

This commit is contained in:
Luke Campagnola 2017-09-13 21:37:19 -07:00
parent 5d6be5796b
commit 6287874b5c
1 changed files with 9 additions and 3 deletions

View File

@ -42,14 +42,20 @@ class HDF5Exporter(Exporter):
dsname = self.params['Name']
fd = h5py.File(fileName, 'a') # forces append to file... 'w' doesn't seem to "delete/overwrite"
data = []
appendAllX = self.params['columnMode'] == '(x,y) per plot'
for i,c in enumerate(self.item.curves):
#print dir(self.item.curves[0])
tlen = 0
for i, c in enumerate(self.item.curves):
d = c.getData()
if i > 0 and len(d[0]) != tlen:
raise ValueError ("HDF5 Export requires all curves in plot to have same length")
if appendAllX or i == 0:
data.append(d[0])
tlen = len(d[0])
data.append(d[1])
fdata = numpy.array(data).astype('double')
dset = fd.create_dataset(dsname, data=fdata)
fd.close()