-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
179 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,69 @@ | ||
import pytest | ||
import dsdtools.audio_classes as ac | ||
import dsdtools | ||
import numpy as np | ||
|
||
|
||
@pytest.fixture(params=['data/DSD100subset']) | ||
def dsd(request): | ||
return dsdtools.DB(root_dir=request.param) | ||
|
||
|
||
def test_targets(dsd): | ||
|
||
tracks = dsd.load_dsd_tracks(ids=1) | ||
|
||
for track in tracks: | ||
for key, target in track.targets.items(): | ||
print target | ||
assert target.audio.shape > 0 | ||
|
||
|
||
def test_rates(dsd): | ||
|
||
tracks = dsd.load_dsd_tracks(ids=1) | ||
|
||
for track in tracks: | ||
assert track.rate == 44100 | ||
assert track.audio.shape > 0 | ||
for key, source in track.sources.items(): | ||
assert source.rate == 44100 | ||
assert source.audio.shape > 0 | ||
|
||
|
||
def test_source(dsd): | ||
|
||
with pytest.raises(ValueError): | ||
source = ac.Source(name="test", path="None") | ||
source.audio | ||
|
||
with pytest.raises(ValueError): | ||
source = ac.Source(name="test", path="None") | ||
source.rate | ||
|
||
source.audio = np.zeros((2, 44100)) | ||
assert source.audio.shape == (2, 44100) | ||
|
||
source.rate = 44100 | ||
assert source.rate == 44100 | ||
|
||
print source | ||
|
||
|
||
def test_track(dsd): | ||
|
||
with pytest.raises(ValueError): | ||
track = ac.Track(name="test", path="None") | ||
track.audio | ||
|
||
with pytest.raises(ValueError): | ||
track = ac.Track(name="test", path="None") | ||
track.rate | ||
|
||
track.audio = np.zeros((2, 44100)) | ||
assert track.audio.shape == (2, 44100) | ||
|
||
track.rate = 44100 | ||
assert track.rate == 44100 | ||
|
||
print track |
This file contains 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,31 @@ | ||
import pytest | ||
import dsdtools | ||
|
||
|
||
def user_function1(track): | ||
'''Pass''' | ||
|
||
# return any number of targets | ||
estimates = { | ||
'vocals': track.audio, | ||
'accompaniment': track.audio, | ||
} | ||
return estimates | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"method", | ||
[ | ||
'mir_eval', | ||
pytest.mark.xfail('not_a_function', raises=ValueError) | ||
] | ||
) | ||
def test_evaluate(method): | ||
|
||
dsd = dsdtools.DB(root_dir="data/DSD100subset", evaluation=method) | ||
|
||
# process dsd but do not save the results | ||
assert dsd.evaluate( | ||
user_function=user_function1, | ||
ids=1 | ||
) |
This file contains 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