Skip to content

Fix .s16/.f32/.r30 loading on numpy >= 2.0#1049

Merged
happycube merged 1 commit into
happycube:mainfrom
staffanu:fix-numpy2-loaders
Jul 17, 2026
Merged

Fix .s16/.f32/.r30 loading on numpy >= 2.0#1049
happycube merged 1 commit into
happycube:mainfrom
staffanu:fix-numpy2-loaders

Conversation

@staffanu

Copy link
Copy Markdown
Contributor

Summary

np.fromstring was removed in numpy 2.0. The uint8/uint16 loaders in lddecode/utils.py were already converted to np.frombuffer, but the int16 (.s16), float32 (.f32), and packed r30 paths still used fromstring and fail with a ValueError on current numpy:

ValueError: The binary mode of fromstring is removed, use frombuffer instead

This makes the raw sample formats unloadable in any environment with numpy 2.x (including the repo's own nix dev shell).

Testing

Verified by decoding a raw .s16 file with the fixed loader (numpy 2.3). The two already-converted loaders (u8/u16) show the pattern is equivalent; frombuffer returns a read-only view, which is fine here since the float32 path immediately creates a new array and the int16 path is only read from.

(Found while writing an end-to-end test for the upcoming AC3 PR, which synthesizes a .s16 input — that PR currently carries this same commit and will be rebased once this merges.)

np.fromstring was removed in numpy 2.0; the uint8/uint16 loaders were
already converted to np.frombuffer but the int16, float32, and packed
r30 paths still used fromstring and failed with a ValueError.  This
made the raw sample formats unloadable on current numpy (the nix
environment ships numpy 2.x); found because the AC3 end-to-end test
reads a synthetic .s16 file.
@happycube
happycube merged commit bd2e6d3 into happycube:main Jul 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants