Skip to content

Commit b64e5c9

Browse files
magrubercbespin
andauthored
MAINT: Prevent OverflowError in multiplication (#230)
* MAINT: Prevent OverflowError in multiplication In newer numpy versions the multiplication of ndarrays containing uint8 results in uint8. Here this leads to an OverflowError. Therefore changing to an uint64 before the multiplication prevents this. --------- Co-authored-by: Christian Bespin <cbespin@uni-bonn.de>
1 parent 248ae12 commit b64e5c9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

basil/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def bitarray_to_byte_array(bitarr):
4141
ba = bitarray(bitarr, endian=bitarr.endian())
4242
ba.reverse() # this flip the byte order and the bit order of each byte
4343
bs = np.frombuffer(ba.tobytes(), dtype=np.uint8) # byte padding happens here, bitarray.tobytes()
44-
bs = (bs * 0x0202020202 & 0x010884422010) % 1023
44+
bs = (bs * np.uint64(0x0202020202) & 0x010884422010) % 1023
4545
return array('B', bs.astype(np.uint8))
4646

4747

0 commit comments

Comments
 (0)