Skip to content

Commit

Permalink
pyscanfcs/openfile.py: fix for numpy 2.0. (#19)
Browse files Browse the repository at this point in the history
As initially identified in [Debian bug #1095368], test_open_dat fails
with numpy 2.0 and beyond with the following error:

	            # Make a 32 bit array
	            data = np.uint32(data16)
	>           data[occ] = data16[occ + 1] + data16[occ + 2] * 65536
	E           OverflowError: Python integer 65536 out of bounds for uint16

This change uses the freshly converted data array to uint32 for the
data concatenation instead of using the uint16 data16 array elements.

[Debian bug #1095368]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1095368
  • Loading branch information
emollier authored Feb 9, 2025
1 parent 35ba085 commit fd36e54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pyscanfcs/openfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def openDAT(path, callback=None, cb_kwargs={}):

# Make a 32 bit array
data = np.uint32(data16)
data[occ] = data16[occ + 1] + data16[occ + 2] * 65536
data[occ] = data[occ + 1] + data[occ + 2] * 65536

if callback is not None:
ret = callback(**cb_kwargs)
Expand Down

0 comments on commit fd36e54

Please sign in to comment.