def test_ns_mood_thayer_valid(): ann = Annotation(namespace='mood_thayer') ann.append(time=0, duration=1.0, value=[0.3, 2.0]) ann.validate()
def test_ns_tempo_valid(): ann = Annotation(namespace='tempo') ann.append(time=0, duration=0, value=1, confidence=0.85) ann.validate()
def test_ns_time_valid(): ann = Annotation(namespace='onset') for time in np.arange(5.0, 10.0): ann.append(time=time, duration=0.0, value=None, confidence=None) ann.validate()
def test_ns_beat_invalid(): ann = Annotation(namespace='beat') for time in np.arange(5.0): ann.append(time=time, duration=0.0, value='foo', confidence=None) ann.validate()
def test_ns_time_invalid(time, duration): ann = Annotation(namespace='onset') # Bypass the safety checks in append ann.data.add( Observation(time=time, duration=duration, value=None, confidence=None)) ann.validate()
def test_ns_beat_position_valid(): ann = Annotation(namespace='beat_position') ann.append(time=0, duration=1.0, value=dict(position=1, measure=1, num_beats=3, beat_units=4)) ann.validate()
def __test(data): ann = Annotation(namespace='onset') # Bypass the safety chceks in add_observation ann.data.loc[0] = {'time': pd.to_timedelta(data['time'], unit='s'), 'duration': pd.to_timedelta(data['duration'], unit='s'), 'value': None, 'confdence': None} ann.validate()
def __test(data): ann = Annotation(namespace='onset') # Bypass the safety chceks in add_observation ann.data.loc[0] = { 'time': pd.to_timedelta(data['time'], unit='s'), 'duration': pd.to_timedelta(data['duration'], unit='s'), 'value': None, 'confdence': None } ann.validate()
def __test(pitch): ann = Annotation(namespace='pitch_class') ann.append(time=0, duration=1.0, value=pitch) ann.append(time=1.0, duration=1.0, value=pitch) ann.validate()
def __test(pattern): ann = Annotation(namespace='pattern_jku') ann.append(time=0, duration=1.0, value=pattern) ann.append(time=1.0, duration=1.0, value=pattern) ann.validate()
def test_ns_pitch_midi_valid(): ann = Annotation(namespace='pitch_midi') seq_len = 21 # should be odd times = np.arange(seq_len) durations = np.zeros(seq_len) values = np.linspace(-108., 108, seq_len) # includes 0 (odd symmetric) confidences = np.linspace(0, 1., seq_len) confidences[seq_len//2] = None # throw in a None confidence value for (t, d, v, c) in zip(times, durations, values, confidences): ann.append(time=t, duration=d, value=v, confidence=c) ann.validate()
def test_ns_beat_valid(): # A valid example ann = Annotation(namespace='beat') for time in np.arange(5.0): ann.append(time=time, duration=0.0, value=1, confidence=None) for time in np.arange(5.0, 10.0): ann.append(time=time, duration=0.0, value=None, confidence=None) ann.validate()
def test_ns_contour_invalid(): srand() ann = Annotation(namespace='pitch_contour') seq_len = 21 times = np.arange(seq_len) durations = np.zeros(seq_len) values = np.linspace(0, 22050, seq_len) # includes 0 (odd symmetric) ids = np.arange(len(values)) // 4 voicing = np.random.randn(len(ids)) * 2 confidences = np.linspace(0, 1., seq_len) confidences[seq_len // 2] = None # throw in a None confidence value for (t, d, v, c, i, b) in zip(times, durations, values, confidences, ids, voicing): ann.append(time=t, duration=d, value={ 'pitch': v, 'id': i, 'voiced': b }, confidence=c) ann.validate()
def test_ns_chord_roman_missing(key): data = dict(tonic='E', chord='iv64') del data[key] ann = Annotation(namespace='chord_roman') ann.append(time=0, duration=1.0, value=data) ann.validate()
def test_ns_tag_cal10k(tag): ann = Annotation(namespace='tag_cal10k') ann.append(time=0, duration=1, value=tag) ann.validate()
def test_ns_pitch_class_invalid(key, value): data = dict(tonic='E', pitch=7) data[key] = value ann = Annotation(namespace='pitch_class') ann.append(time=0, duration=1.0, value=data) ann.validate()
def test_ns_tag_msd_tagtraum_cd1(tag, confidence): ann = Annotation(namespace='tag_msd_tagtraum_cd1') ann.append(time=0, duration=1, value=tag, confidence=confidence) ann.validate()
def test_ns_beat_position_missing(key): data = dict(position=1, measure=1, num_beats=3, beat_units=4) del data[key] ann = Annotation(namespace='beat_position') ann.append(time=0, duration=1.0, value=data) ann.validate()
def test_ns_chord_roman_invalid(key, value): data = dict(tonic='E', chord='iv64') data[key] = value ann = Annotation(namespace='chord_roman') ann.append(time=0, duration=1.0, value=data) ann.validate()
def test_ns_pattern_invalid_bounded(key, value): data = dict(midi_pitch=3, morph_pitch=5, staff=1, pattern_id=1, occurrence_id=1) data[key] = value ann = Annotation(namespace='pattern_jku') ann.append(time=0, duration=1.0, value=data) ann.validate()
def test_ns_pitch_midi_valid(): ann = Annotation(namespace='pitch_midi') seq_len = 21 times = np.arange(seq_len) durations = np.zeros(seq_len) values = np.linspace(-108., 108, seq_len) # includes 0 (odd symmetric) confidences = np.linspace(0, 1., seq_len) confidences[seq_len // 2] = None # throw in a None confidence value for (t, d, v, c) in zip(times, durations, values, confidences): ann.append(time=t, duration=d, value=v, confidence=c) ann.validate()
def test_ns_scaper_source_file(source_file): ann = Annotation(namespace='scaper') value = { "source_time": 0.0, "event_duration": 0.5310546236891855, "event_time": 5.6543442662431795, "time_stretch": 0.8455598669219283, "pitch_shift": -1.2204911976305648, "snr": 7.790682558359417, "label": "gun_shot", "role": "foreground", "source_file": source_file } ann.append(time=0, duration=1, value=value) ann.validate()
def test_ns_scaper_snr(snr): ann = Annotation(namespace='scaper') value = { "source_time": 0.0, "event_duration": 0.5310546236891855, "event_time": 5.6543442662431795, "time_stretch": 0.8455598669219283, "pitch_shift": -1.2204911976305648, "snr": snr, "label": 'gun_shot', "role": "foreground", "source_file": "/audio/foreground/gun_shot/135544-6-17-0.wav" } ann.append(time=0, duration=1, value=value) ann.validate()
def __test(tag): ann = Annotation(namespace='tag_gtzan') ann.append(time=0, duration=1, value=tag) ann.validate()
def test_segment_tag_open(segment): ann = Annotation(namespace='segment_open') ann.append(time=0, duration=1, value=segment) ann.validate()
def __test(tag): ann = Annotation(namespace='tag_medleydb_instruments') ann.append(time=0, duration=1, value=tag) ann.validate()
def __test(tag, confidence=None): ann = Annotation(namespace='tag_msd_tagtraum_cd2') ann.append(time=0, duration=1, value=tag, confidence=confidence) ann.validate()
def __test(label): ann = Annotation(namespace='segment_salami_function') ann.append(time=0, duration=1, value=label) ann.validate()
def __test(value): ann = Annotation(namespace='mood_thayer') ann.append(time=0, duration=1.0, value=value) ann.validate()
def __test(value): ann = Annotation(namespace='beat_position') ann.append(time=0, duration=1.0, value=value) ann.validate()
def __test(keymode): ann = Annotation(namespace='key_mode') ann.append(time=0, duration=0, value=keymode, confidence=None) ann.validate()
def test_ns_segment_tut(label): ann = Annotation(namespace='segment_tut') ann.append(time=0, duration=1, value=label) ann.validate()
def test_ns_multi_segment_bad(): ann = Annotation(namespace='multi_segment') ann.append(time=0, duration=1, value='a string') ann.validate()
def test_ns_tag_audioset_instruments(tag): ann = Annotation(namespace='tag_audioset_instruments') ann.append(time=0, duration=1, value=tag) ann.validate()
def __test(lyric): ann = Annotation(namespace='lyrics') ann.append(time=0, duration=1, value=lyric) ann.validate()
def test_ns_vector(label): ann = Annotation(namespace='vector') ann.append(time=0, duration=1, value=label) ann.validate()
def __test(value): ann = Annotation(namespace='pitch_midi') ann.append(time=0, duration=0, value=value, confidence=0.5) ann.validate()
def __test(data): ann = Annotation(namespace='onset') ann.append(**data) ann.validate()
def test_ns_blob(label): ann = Annotation(namespace='blob') ann.append(time=0, duration=1, value=label) ann.validate()
def __test(chord): ann = Annotation(namespace='chord_roman') ann.append(time=0, duration=1.0, value=chord) ann.validate()
def test_ns_multi_segment(label, level): ann = Annotation(namespace='multi_segment') ann.append(time=0, duration=1, value=dict(label=label, level=level)) ann.validate()
def __test(value, confidence): ann = Annotation(namespace='tempo') ann.append(time=0, duration=0, value=value, confidence=confidence) ann.validate()
def test_ns_lyrics_bow(label): ann = Annotation(namespace='lyrics_bow') ann.append(time=0, duration=1, value=label) ann.validate()
def __test(label): ann = Annotation(namespace='vector') ann.append(time=0, duration=1, value=label) ann.validate()
def test_ns_tag_fma_subgenre(tag): ann = Annotation(namespace='tag_fma_subgenre') ann.append(time=0, duration=1, value=tag) ann.validate()
def __test(value): ann = Annotation(namespace='multi_segment') ann.append(time=0, duration=1, value=value) ann.validate()