tests: Fix input_signal variable in test_returned_sample_count being too short#385
Merged
hyperc54 merged 2 commits intospotify:masterfrom May 12, 2025
Merged
Conversation
hyperc54
commented
Nov 10, 2024
tests/test_stream_resampler.py
Outdated
| input_signal = np.linspace(0, 3, num=int(sample_rate), dtype=np.float32) | ||
| resampler = StreamResampler(sample_rate, target_sample_rate, 1, quality) | ||
|
|
||
| print("input", input_signal) |
Collaborator
Author
There was a problem hiding this comment.
This may need to go too?
Member
|
Thanks @hyperc54! (And so sorry for the delay; I haven't had much time for Pedalboard maintenance in the past couple of months.) |
8712464 to
fd7b45e
Compare
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.
Problem
I believe the way the
input_signalvariable (in thetest_returned_sample_counttest) is currently defined on master may contain a typo.I would expect
input_signalto represent a realistic input that would contain 1s worth of samples for different sample rates.Currently, it always contain 3 samples, which makes the different chunk sizes testing mostly worthless.
Solution
Switching the order of parameters when calling
np.linspacecreates a more realistic input (mostly, a longer array).I kept using np.linspace instead of switching to np.rand (that might be more realistic?) because
np.linspaceis probably faster to run.Result
The test is still green, but it now more accurately covers/tests all different chunk_sizes scenarios.
Additional context
I was working on fixing issue #287 (which I believe I may have a fix for) and I wanted to amend the
returned_sample_counttest to make it cover the problem highlighted in #287. The way np.linspace was called surprised me so I first want to make sure Im understanding this properly :)