Fix .s16/.f32/.r30 loading on numpy >= 2.0#1049
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
np.fromstringwas removed in numpy 2.0. The uint8/uint16 loaders inlddecode/utils.pywere already converted tonp.frombuffer, but the int16 (.s16), float32 (.f32), and packed r30 paths still usedfromstringand fail with aValueErroron current numpy: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
.s16file with the fixed loader (numpy 2.3). The two already-converted loaders (u8/u16) show the pattern is equivalent;frombufferreturns 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
.s16input — that PR currently carries this same commit and will be rebased once this merges.)