Skip to content

Commit

Permalink
mdf4reader : corrected bug with format for struct in case of invalid …
Browse files Browse the repository at this point in the history
…bytes
  • Loading branch information
ratal committed May 11, 2015
1 parent 51ec422 commit c6ac0a6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mdf4reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,12 @@ def readBitarray(self, bita, channelList=None):
byte = 8 * (self[chan].nBytes - nbytes) * bitarray([False])
for i in range(self.numberOfRecords): # extend data of bytes to match numpy requirement
temp[i].append(byte)
temp = [self[chan].CFormat.unpack(temp[i].tobytes())[0] \
for i in range(self.numberOfRecords)]
if 's' not in self[chan].Format:
temp = [self[chan].CFormat.unpack(temp[i].tobytes())[0] \
for i in range(self.numberOfRecords)]
else:
temp = [temp[i].tobytes() \
for i in range(self.numberOfRecords)]
buf[self[chan].name] = asarray(temp)
return buf

Expand Down Expand Up @@ -1342,7 +1346,7 @@ def arrayformat4(signalDataType, numberOfBits):
elif numberOfBits <= 64:
dataType = 'u8'
else:
dataType = 'u1'
dataType = str(bits_to_bytes(numberOfBits) // 8) + 'V'

elif signalDataType in (2, 3): # signed int
if numberOfBits <= 8:
Expand Down Expand Up @@ -1412,7 +1416,7 @@ def datatypeformat4(signalDataType, numberOfBits):
elif numberOfBits <= 64:
dataType = 'L'
else:
dataType = 'u1'
dataType = str(bits_to_bytes(numberOfBits) // 8) + 's'

elif signalDataType in (2, 3): # signed int
if numberOfBits <= 8:
Expand Down

0 comments on commit c6ac0a6

Please sign in to comment.