Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pyrat/lib/ste/ste_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def create(self, shape=None, header=None, **kwargs):
self.Header.Rat.rattype = ctypes.c_int(kwargs['rattype'])

# calculate the needed size of an empty file
n_bytes = reduce(lambda x, y: x * y, self.shape) * self.dtype.itemsize
n_bytes = np.prod(self.shape) * self.dtype.itemsize

# write the Header and truncate the file
with open(self.filename, 'wb') as lun:
Expand Down Expand Up @@ -532,8 +532,7 @@ def write(self, arr=[], **kwargs):
self.Header.Rat.ndim = ctypes.c_int(len(self.shape))
self.Header.Rat.nchannel = ctypes.c_int(int(np.prod(self.shape[2:])))

n_bytes_total = (
1000 + reduce(lambda x, y: x * y, self.shape) * self.dtype.itemsize)
n_bytes_total = 1000 + np.prod(self.shape) * self.dtype.itemsize

with open(self.filename, 'wb') as lun:
lun.write(self.Header)
Expand Down Expand Up @@ -664,7 +663,7 @@ def append(self, arr):
self._ioerror('The shape specified in the header %s and the shape of '
'the array %s don\'t correspond to each other!' % (str(self.shape[1:]),str(arr.shape[1:])))

n_bytes_total = 1000 + reduce(lambda x, y: x * y, self.shape) * arr.itemsize
n_bytes_total = 1000 + np.prod(self.shape) * self.dtype.itemsize

with open(self.filename, 'r+b') as lun:
lun.seek(0,2)
Expand Down