-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve python pytest warnings and deprecations #155
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
seonghobae
wants to merge
5
commits into
develop
Choose a base branch
from
fix/issue-153-warnings-deprecations
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
5 commits
Select commit
Hold shift + click to select a range
c773fa7
fix: suppress RuntimeWarning when executing cli as main module
seonghobae eb30664
Merge feature branch and keep PR 149's warning fixes
seonghobae f849bab
Merge remote-tracking branch 'origin/fix/issue-148-ci-pipeline' into …
seonghobae e786668
fix: resolve python pytest warnings and deprecations
seonghobae 1721a4f
Merge branch 'develop' into fix/issue-153-warnings-deprecations
seonghobae 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 |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ def test_chord_recognizer_c_major_chord() -> None: | |
| """Test chord recognition with a clear C major chord.""" | ||
| recognizer = ChordRecognizer() | ||
| sr = 22050 | ||
| t = np.linspace(0, 1.0, sr) | ||
| t = np.linspace(0, 3.0, sr * 3, endpoint=False) | ||
| # C major: C4 (261.63Hz), E4 (329.63Hz), G4 (392.00Hz) | ||
| y = ( | ||
| np.sin(2 * np.pi * 261.63 * t) | ||
|
|
@@ -47,7 +47,7 @@ def test_chord_recognizer_c_major_chord() -> None: | |
| def test_chord_recognizer_hpss_exception(): | ||
| """Test for test_chord_recognizer_hpss_exception.""" | ||
| recognizer = ChordRecognizer() | ||
| y = np.random.randn(22050) | ||
| y = np.random.randn(22050 * 3) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial 반복되는 샘플 수 계산은 상수/헬퍼로 통일하는 것이 좋습니다. 현재 패턴이 여러 테스트에 반복되어, 샘플링 레이트나 길이 변경 시 수정 지점이 많아집니다. 공통 상수/헬퍼로 추출하면 유지보수성이 좋아집니다. 예시 리팩터링 diff import numpy as np
from bandscope_analysis.chords.chord_recognizer import ChordRecognizer
+SR = 22050
+DURATION_SEC = 3
+
+
+def _noise_signal(sr: int = SR, duration_sec: int = DURATION_SEC) -> np.ndarray:
+ return np.random.randn(sr * duration_sec)
@@
def test_chord_recognizer_hpss_exception():
@@
- y = np.random.randn(22050 * 3)
+ y = _noise_signal()
@@
def test_chord_recognizer_chroma_cqt_exception():
@@
- y = np.random.randn(22050 * 3)
+ y = _noise_signal()
@@
def test_chord_recognizer_rms_exception():
@@
- y = np.random.randn(22050 * 3)
+ y = _noise_signal()
@@
def test_chord_recognizer_rms_padding():
@@
- y = np.random.randn(22050 * 3)
+ y = _noise_signal()
@@
def test_chord_recognizer_empty_chromagram():
@@
- y = np.random.randn(22050 * 3)
+ y = _noise_signal()
@@
def test_chord_recognizer_rms_longer():
@@
- y = np.random.randn(22050 * 3)
+ y = _noise_signal()Also applies to: 60-60, 70-70, 80-80, 94-94, 105-105 🤖 Prompt for AI Agents |
||
|
|
||
| with patch("librosa.effects.hpss", side_effect=Exception("HPSS Error")): | ||
| chords = recognizer.recognize(y, sr=22050) | ||
|
|
@@ -57,7 +57,7 @@ def test_chord_recognizer_hpss_exception(): | |
| def test_chord_recognizer_chroma_cqt_exception(): | ||
| """Test for test_chord_recognizer_chroma_cqt_exception.""" | ||
| recognizer = ChordRecognizer() | ||
| y = np.random.randn(22050) | ||
| y = np.random.randn(22050 * 3) | ||
|
|
||
| with patch("librosa.feature.chroma_cqt", side_effect=Exception("CQT Error")): | ||
| chords = recognizer.recognize(y, sr=22050) | ||
|
|
@@ -67,7 +67,7 @@ def test_chord_recognizer_chroma_cqt_exception(): | |
| def test_chord_recognizer_rms_exception(): | ||
| """Test for test_chord_recognizer_rms_exception.""" | ||
| recognizer = ChordRecognizer() | ||
| y = np.random.randn(22050) | ||
| y = np.random.randn(22050 * 3) | ||
|
|
||
| with patch("librosa.feature.rms", side_effect=Exception("RMS Error")): | ||
| chords = recognizer.recognize(y, sr=22050) | ||
|
|
@@ -77,7 +77,7 @@ def test_chord_recognizer_rms_exception(): | |
| def test_chord_recognizer_rms_padding(): | ||
| """Test for test_chord_recognizer_rms_padding.""" | ||
| recognizer = ChordRecognizer() | ||
| y = np.random.randn(22050) | ||
| y = np.random.randn(22050 * 3) | ||
|
|
||
| # Mock RMS to return something shorter than chromagram | ||
| def mock_rms(*args, **kwargs): | ||
|
|
@@ -91,7 +91,7 @@ def mock_rms(*args, **kwargs): | |
| def test_chord_recognizer_empty_chromagram(): | ||
| """Test for test_chord_recognizer_empty_chromagram.""" | ||
| recognizer = ChordRecognizer() | ||
| y = np.random.randn(22050) | ||
| y = np.random.randn(22050 * 3) | ||
|
|
||
| # Mock chroma_cqt to return empty array | ||
| with patch("librosa.feature.chroma_cqt", return_value=np.array([])): | ||
|
|
@@ -102,7 +102,7 @@ def test_chord_recognizer_empty_chromagram(): | |
| def test_chord_recognizer_rms_longer(): | ||
| """Test for test_chord_recognizer_rms_longer.""" | ||
| recognizer = ChordRecognizer() | ||
| y = np.random.randn(22050) | ||
| y = np.random.randn(22050 * 3) | ||
|
|
||
| # Mock RMS to return something longer than chromagram | ||
| def mock_rms(*args, **kwargs): | ||
|
|
@@ -118,15 +118,15 @@ def test_chord_recognizer_changing_chords(): | |
| """Test for test_chord_recognizer_changing_chords.""" | ||
| recognizer = ChordRecognizer() | ||
| sr = 22050 | ||
| t1 = np.linspace(0, 1.0, sr, endpoint=False) | ||
| t1 = np.linspace(0, 3.0, sr * 3, endpoint=False) | ||
| # C major | ||
| y1 = ( | ||
| np.sin(2 * np.pi * 261.63 * t1) | ||
| + np.sin(2 * np.pi * 329.63 * t1) | ||
| + np.sin(2 * np.pi * 392.00 * t1) | ||
| ) / 3.0 | ||
|
|
||
| t2 = np.linspace(0, 1.0, sr, endpoint=False) | ||
| t2 = np.linspace(0, 3.0, sr * 3, endpoint=False) | ||
| # G major: G4 (392.00Hz), B4 (493.88Hz), D5 (587.33Hz) | ||
| y2 = ( | ||
| np.sin(2 * np.pi * 392.00 * t2) | ||
|
|
||
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
Oops, something went wrong.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: seonghobae/bandscope
Length of output: 357
🏁 Script executed:
Repository: seonghobae/bandscope
Length of output: 1495
🏁 Script executed:
Repository: seonghobae/bandscope
Length of output: 569
🏁 Script executed:
Repository: seonghobae/bandscope
Length of output: 850
librosa.load() 호출 시 특정 모듈로 경고 필터링 범위 좁히기
DeprecationWarning/FutureWarning전체를 무시하면 라이브러리 업그레이드 시 호환성 문제를 조기에 탐지하기 어렵습니다. audioread(librosa의 음성 로드 백엔드)에서만 이 경고들을 무시하도록 범위를 좁혀주세요.제안 수정
🤖 Prompt for AI Agents