Skip to content

tests: Fix input_signal variable in test_returned_sample_count being too short#385

Merged
hyperc54 merged 2 commits intospotify:masterfrom
hyperc54:pierret/fix_returned_sample_count_test
May 12, 2025
Merged

tests: Fix input_signal variable in test_returned_sample_count being too short#385
hyperc54 merged 2 commits intospotify:masterfrom
hyperc54:pierret/fix_returned_sample_count_test

Conversation

@hyperc54
Copy link
Collaborator

@hyperc54 hyperc54 commented Nov 10, 2024

Problem

I believe the way the input_signal variable (in the test_returned_sample_count test) is currently defined on master may contain a typo.
I would expect input_signal to 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.linspace creates 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.linspace is 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_count test 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 :)

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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to go too?

@psobot
Copy link
Member

psobot commented Mar 14, 2025

Thanks @hyperc54! (And so sorry for the delay; I haven't had much time for Pedalboard maintenance in the past couple of months.)

@hyperc54 hyperc54 force-pushed the pierret/fix_returned_sample_count_test branch from 8712464 to fd7b45e Compare May 12, 2025 15:16
@hyperc54 hyperc54 merged commit f0ac734 into spotify:master May 12, 2025
35 checks passed
@psobot psobot added enhancement New feature or request good first issue Good for newcomers labels May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants