-
Notifications
You must be signed in to change notification settings - Fork 14
feature/add_schroeder_frequency_function #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SitChri
wants to merge
10
commits into
pyfar:develop
Choose a base branch
from
SitChri:feature/schroeder
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
67ab825
The Minisitry of Silly Coding introduces a new equation for computing…
SitChri e3a1cfb
changes for the request from the latest pull request (schroeder frequ…
SitChri 3b25a8e
change schroeder_freq to schroeder_frequency
SitChri a2641e1
add input check for volume and reverberation time.
SitChri 2b03d4c
delete trailing white space
SitChri f7e3391
make lines shorter ... delete whitespace
SitChri ee29225
minor documentation changes
SitChri b912be8
delete type annotations
SitChri e5f4524
adding tests for schroeder frequency
SitChri cece9cd
changes for tests and schroeder frequency
SitChri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import numpy as np | ||
| import pytest | ||
| from pyrato.parametric import schroeder_frequency | ||
|
|
||
| def test_schroeder_frequency_scalar(): | ||
| """Test with scalar float inputs.""" | ||
| f_s = schroeder_frequency(100.0, 1.0) | ||
| expected = 2000 * np.sqrt(1.0 / 100.0) | ||
| assert np.isclose(f_s, expected) | ||
|
|
||
|
|
||
| def test_schroeder_frequency_array(): | ||
| """Test with matching array inputs.""" | ||
| volumes = np.array([100.0, 200.0, 400.0]) | ||
| reverb_times = np.array([1.0, 2.0, 4.0]) | ||
| f_s = schroeder_frequency(volumes, reverb_times) | ||
| expected = 2000 * np.sqrt(reverb_times / volumes) | ||
| np.testing.assert_allclose(f_s, expected,rtol=1e-5) | ||
|
|
||
|
|
||
| def test_schroeder_frequency_broadcasting(): | ||
| """Test with scalar and array combination (broadcasting).""" | ||
| volume = 100.0 | ||
| reverb_times = np.array([0.5, 1.0, 2.0]) | ||
| with pytest.raises(ValueError, match="volume and reverberation_time " \ | ||
| "must have compatible shapes, either same shape or one is scalar."): | ||
| schroeder_frequency(volume, reverb_times) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("volume", "reverb_time"), [(0, 1.0), | ||
| (-10, 1.0), | ||
| (100, 0), | ||
| (100, -2)]) | ||
| def test_invalid_values(volume, reverb_time): | ||
| """Test that non-positive values raise ValueError.""" | ||
| with pytest.raises(ValueError, match="volume and reverberation_time " \ | ||
| "must be positiv"): | ||
| schroeder_frequency(volume, reverb_time) | ||
|
|
||
|
|
||
| def test_shape_mismatch(): | ||
| """Test that mismatched shapes raise ValueError.""" | ||
| volumes = np.array([100, 200]) | ||
| reverb_times = np.array([1.0, 2.0, 3.0]) | ||
| with pytest.raises(ValueError, match="volume and reverberation_time " \ | ||
| "must have compatible shapes, either same shape or one is scalar."): | ||
| schroeder_frequency(volumes, reverb_times) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize(("volume", "reverb_time"), [ | ||
| ("abc", 1.0), | ||
| (100, "1.0"), | ||
| (None, 1.0), | ||
| ]) | ||
| def test_invalid_types(volume, reverb_time): | ||
| """Test that non-numeric inputs raise TypeError.""" | ||
| with pytest.raises(TypeError): | ||
| schroeder_frequency(volume, reverb_time) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the source - the citation is broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice hint, but we don´t know how ... seems as broken as for energy_decay_curve_analytic function below.