Skip to content

Commit 13864e1

Browse files
committed
Fixed a minor bug that caused the code to crash when the buffer is flushed more than once
1 parent 4f9a4ad commit 13864e1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

abie/data_io.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ def flush(self):
7373
Write the simulation data buffer to the HDF5 file unconditionally.
7474
:return:
7575
"""
76+
if self.buf_cursor == 0:
77+
# already flushed
78+
return
7679

7780
if self.h5_file is None:
7881
self.h5_file = h5py.File(self.output_file_name, 'w')
7982
self.h5_file.attrs['G'] = self.CONST_G
8083
h5_step_group = self.h5_file.create_group('Step#%d' % self.h5_step_id)
81-
84+
8285
state_dict = {
8386
'time': self.buf_t[:self.buf_cursor],
8487
'mass': self.buf_mass[:self.buf_cursor],

0 commit comments

Comments
 (0)