Skip to content

Commit

Permalink
Merge branch 'master' into driver-n5245a
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen authored Jul 20, 2018
2 parents 1da1635 + bcedfbc commit 3d76208
Show file tree
Hide file tree
Showing 42 changed files with 4,958 additions and 657 deletions.

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions qcodes/data/hdf5_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class HDF5Format(Formatter):
HDF5 formatter for saving qcodes datasets.
Capable of storing (write) and recovering (read) qcodes datasets.
"""

_format_tag = 'hdf5'

def close_file(self, data_set):
"""
Closes the hdf5 file open in the dataset.
Args:
data_set (DataSet): DataSet object
"""
Expand Down Expand Up @@ -99,6 +99,9 @@ def read(self, data_set, location=None):
# set_arrays = ()
vals = dat_arr.value[:, 0]
if 'shape' in dat_arr.attrs.keys():
# extend with NaN if needed
esize = np.prod(dat_arr.attrs['shape'])
vals = np.append(vals, [np.nan] * (esize - vals.size))
vals = vals.reshape(dat_arr.attrs['shape'])
if array_id not in data_set.arrays.keys(): # create new array
d_array = DataArray(
Expand Down Expand Up @@ -207,7 +210,12 @@ def write(self, data_set, io_manager=None, location=None,
datasetshape = dset.shape
old_dlen = datasetshape[0]
x = data_set.arrays[array_id]
new_dlen = len(x[~np.isnan(x)])
try:
# get latest NaN element
new_dlen = (~np.isnan(x)).flatten().nonzero()[0][-1] + 1
except IndexError:
new_dlen = old_dlen

new_datasetshape = (new_dlen,
datasetshape[1])
dset.resize(new_datasetshape)
Expand Down
Loading

0 comments on commit 3d76208

Please sign in to comment.