Skip to content

Commit

Permalink
WIP normpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcortes committed Oct 22, 2023
1 parent 50005b8 commit ac07a11
Show file tree
Hide file tree
Showing 22 changed files with 726 additions and 479 deletions.
40 changes: 24 additions & 16 deletions tests/datasets/test_cante100.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,32 @@ def test_track():
expected_attributes = {
"artist": "Toronjo",
"duration": 179.0,
"audio_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100audio/008_PacoToronjo_Fandangos.mp3"
)),
"f0_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100midi_f0/008_PacoToronjo_Fandangos.f0.csv"
)),
"audio_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100audio/008_PacoToronjo_Fandangos.mp3",
)
),
"f0_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100midi_f0/008_PacoToronjo_Fandangos.f0.csv",
)
),
"identifier": "4eebe839-82bb-426e-914d-7c4525dd9dad",
"notes_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100_automaticTranscription/008_PacoToronjo_Fandangos.notes.csv"
)),
"notes_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100_automaticTranscription/008_PacoToronjo_Fandangos.notes.csv",
)
),
"release": "Atlas del cante flamenco",
"spectrogram_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100_spectrum/008_PacoToronjo_Fandangos.spectrum.csv"
)),
"spectrogram_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/cante100/",
"cante100_spectrum/008_PacoToronjo_Fandangos.spectrum.csv",
)
),
"title": "Huelva Como Capital",
"track_id": "008",
}
Expand Down
58 changes: 39 additions & 19 deletions tests/datasets/test_carnatic_rhythm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ def test_track():

expected_attributes = {
"track_id": "10003",
"audio_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm/",
"CMR_subset_1.0/audio/01_10003_1-04_Shri_Visvanatham.wav"
)),
"beats_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm/",
"CMR_subset_1.0/annotations/beats/01_10003_1-04_Shri_Visvanatham.beats"
)),
"meter_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm/",
"CMR_subset_1.0/annotations/meter/01_10003_1-04_Shri_Visvanatham.meter"
)),
"audio_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm/",
"CMR_subset_1.0/audio/01_10003_1-04_Shri_Visvanatham.wav",
)
),
"beats_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm/",
"CMR_subset_1.0/annotations/beats/01_10003_1-04_Shri_Visvanatham.beats",
)
),
"meter_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm/",
"CMR_subset_1.0/annotations/meter/01_10003_1-04_Shri_Visvanatham.meter",
)
),
}

expected_property_types = {
Expand All @@ -52,7 +58,9 @@ def test_track():


def test_to_jams():
data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="test")
track = dataset.track("10003")
jam = track.to_jams()
Expand Down Expand Up @@ -81,7 +89,9 @@ def test_to_jams():


def test_load_meter():
data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="test")
track = dataset.track("10003")
meter_path = track.meter_path
Expand All @@ -91,7 +101,9 @@ def test_load_meter():


def test_load_beats():
data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="test")
track = dataset.track("10003")
beats_path = track.beats_path
Expand All @@ -107,7 +119,9 @@ def test_load_beats():
assert np.array_equal(parsed_beats.positions, np.array([1, 2, 3]))
assert compmusic_carnatic_rhythm.load_beats(None) is None

data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="full_dataset")
track = dataset.track("10001")
beats_path = track.beats_path
Expand All @@ -116,7 +130,9 @@ def test_load_beats():


def test_load_metadata():
data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="test")
meta = dataset._metadata # get dataset metadata
parsed_metadata = meta["10003"] # get track metadata
Expand All @@ -129,7 +145,9 @@ def test_load_metadata():
assert parsed_metadata["num_of_beats"] == 162
assert parsed_metadata["num_of_samas"] == 21

data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="full_dataset")
meta = dataset._metadata # get dataset metadata
parsed_metadata = meta["10001"] # get track metadata
Expand All @@ -145,7 +163,9 @@ def test_load_metadata():


def test_load_audio():
data_home = os.path.normpath("tests/resources/mir_datasets/compmusic_carnatic_rhythm")
data_home = os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_rhythm"
)
dataset = compmusic_carnatic_rhythm.Dataset(data_home, version="test")
track = dataset.track("10003")
audio_path = track.audio_path
Expand Down
44 changes: 24 additions & 20 deletions tests/datasets/test_carnatic_varnam.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,33 @@ def test_track():

expected_attributes = {
"track_id": "dharini_abhogi",
"audio_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/",
"Audio/223578__gopalkoduri__carnatic-varnam-by-dharini-in-abhogi-raaga.mp3",
)
"audio_path": os.path.join(
os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/"
),
os.path.normpath(
"Audio/223578__gopalkoduri__carnatic-varnam-by-dharini-in-abhogi-raaga.mp3"
),
),
"taala_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/",
"Notations_Annotations/annotations/taalas/abhogi/dharini.svl",
)
"taala_path": os.path.join(
os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/"
),
os.path.normpath(
"Notations_Annotations/annotations/taalas/abhogi/dharini.svl"
),
),
"notation_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/",
"Notations_Annotations/notations/abhogi.yaml",
)
"notation_path": os.path.join(
os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/"
),
os.path.normpath("Notations_Annotations/notations/abhogi.yaml"),
),
"structure_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/",
"Notations_Annotations/notations/abhogi/dharini.yaml",
)
"structure_path": os.path.join(
os.path.normpath(
"tests/resources/mir_datasets/compmusic_carnatic_varnam/carnatic_varnam_1.1/"
),
os.path.normpath("Notations_Annotations/notations/abhogi/dharini.yaml"),
),
"artist": "dharini",
"raaga": "abhogi",
Expand Down
118 changes: 69 additions & 49 deletions tests/datasets/test_compmusic_raga.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,55 @@ def test_track():

expected_attributes = {
"track_id": "Aruna_Sairam.Valli_Kanavan",
"audio_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/audio/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.mp3"
)),
"tonic_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.tonic"
)),
"tonic_fine_tuned_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.tonicFine"
)),
"pitch_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.pitch"
)),
"pitch_post_processed_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.pitchSilIntrpPP",
)),
"nyas_segments_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.flatSegNyas"
)),
"tani_segments_path": os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.taniSegKNN"
)),
"audio_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/audio/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.mp3",
)
),
"tonic_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.tonic",
)
),
"tonic_fine_tuned_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.tonicFine",
)
),
"pitch_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.pitch",
)
),
"pitch_post_processed_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.pitchSilIntrpPP",
)
),
"nyas_segments_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.flatSegNyas",
)
),
"tani_segments_path": os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/",
"RagaDataset/Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/Valli_Kanavan/",
"Valli_Kanavan.taniSegKNN",
)
),
}

expected_property_types = {
Expand Down Expand Up @@ -216,11 +230,13 @@ def test_load_pitch():

assert compmusic_raga.load_pitch(None) is None

empty_pitch_path = os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/RagaDataset/",
"Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/",
"Valli_Kanavan/Valli_Kanavan_empty.pitch"
))
empty_pitch_path = os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/RagaDataset/",
"Carnatic/features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/",
"Valli_Kanavan/Valli_Kanavan_empty.pitch",
)
)
assert compmusic_raga.load_pitch(empty_pitch_path) is None


Expand Down Expand Up @@ -268,15 +284,19 @@ def test_load_segments():
assert compmusic_raga.load_nyas_segments(None) is None
assert compmusic_raga.load_tani_segments(None) is None

empty_nyas_path = os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/RagaDataset/Carnatic/",
"features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/",
"Valli_Kanavan/Valli_Kanavan_empty.flatSegNyas"
))
empty_tani_path = os.path.normpath(os.path.join(
"tests/resources/mir_datasets/compmusic_raga/RagaDataset/Carnatic/",
"features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/",
"Valli_Kanavan/Valli_Kanavan_empty.taniSegKNN"
empty_nyas_path = os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/RagaDataset/Carnatic/",
"features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/",
"Valli_Kanavan/Valli_Kanavan_empty.flatSegNyas",
)
)
empty_tani_path = os.path.normpath(
os.path.join(
"tests/resources/mir_datasets/compmusic_raga/RagaDataset/Carnatic/",
"features/3af5a361-923a-465d-864d-9c7ba0c04a47/Aruna_Sairam/December_Season_2001/",
"Valli_Kanavan/Valli_Kanavan_empty.taniSegKNN",
)
)
assert compmusic_raga.load_nyas_segments(empty_nyas_path) is None
assert compmusic_raga.load_tani_segments(empty_tani_path) is None
Expand Down
Loading

0 comments on commit ac07a11

Please sign in to comment.