Skip to content

Commit

Permalink
Merge pull request #378 from qipe-nlab/fix-append-mode
Browse files Browse the repository at this point in the history
Fix the wrong selection of AppendMode in DDH5Writer.add_data
  • Loading branch information
marcosfrenkel committed Mar 17, 2023
2 parents 0dfb214 + bf3128e commit a31334e
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions plottr/data/datadict_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ def __init__(self,

self.basedir = Path(basedir)
self.datadict = datadict
self.inserted_rows = 0

if name is None:
name = ''
Expand Down Expand Up @@ -619,7 +618,6 @@ def __enter__(self) -> "DDH5Writer":
groupname=self.groupname,
append_mode=AppendMode.none,
file_timeout=self.file_timeout)
self.inserted_rows = nrecords
return self

def __exit__(self,
Expand Down Expand Up @@ -681,16 +679,10 @@ def add_data(self, **kwargs: Any) -> None:
an outer dimension with length 1 is added for all.
"""
self.datadict.add_data(**kwargs)

if self.inserted_rows > 0:
mode = AppendMode.new
else:
mode = AppendMode.none
nrecords = self.datadict.nrecords()
if nrecords is not None and nrecords > 0:
datadict_to_hdf5(self.datadict, str(self.filepath),
groupname=self.groupname,
append_mode=mode,
file_timeout=self.file_timeout)

assert self.filepath is not None
Expand Down

0 comments on commit a31334e

Please sign in to comment.