Skip to content

Commit bd2e6d3

Browse files
authored
Merge pull request #1049 from staffanu/fix-numpy2-loaders
Fix .s16/.f32/.r30 loading on numpy >= 2.0
2 parents 8a42fec + 1bbbf90 commit bd2e6d3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lddecode/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ def load_unpacked_data(infile, sample, readlen, sampletype):
290290
inbuf = infile.read(readlen * samplelength)
291291

292292
if sampletype == 4:
293-
indata = np.fromstring(inbuf, "float32", len(inbuf) // 4) * 32768
293+
indata = np.frombuffer(inbuf, "float32", len(inbuf) // 4) * 32768
294294
elif sampletype == 3:
295295
indata = np.frombuffer(inbuf, "uint16", len(inbuf) // 2)
296296
elif sampletype == 2:
297-
indata = np.fromstring(inbuf, "int16", len(inbuf) // 2)
297+
indata = np.frombuffer(inbuf, "int16", len(inbuf) // 2)
298298
else:
299299
# NOTE(oln): Can probably use frombuffer for other variants too but
300300
# didn't have any samples to test with.
@@ -334,7 +334,7 @@ def load_packed_data_3_32(infile, sample, readlen):
334334
needed = int(np.ceil(readlen * 3 / 4) * 4) + 4
335335

336336
inbuf = infile.read(needed)
337-
indata = np.fromstring(inbuf, "uint32", len(inbuf) // 4)
337+
indata = np.frombuffer(inbuf, "uint32", len(inbuf) // 4)
338338

339339
if len(indata) < needed:
340340
return None

0 commit comments

Comments
 (0)