<commit_before>#!/usr/bin/env python
# CREATED:2013-03-11 18:14:30 by <NAME> <<EMAIL>>
#  unit tests for librosa.beat


import librosa, numpy, scipy.io

from testLibrosaCore import files, load

def test_onset_strength():

    def __test(infile):
        DATA    = load(infile)

        # Compute onset envelope using the same spectrogram
        onsets  = librosa.beat.onset_strength(y=None, sr=8000, S=DATA['D'])

        assert numpy.allclose(onsets, DATA['onsetenv'][0])

        pass

    for infile in files('data/beat-onset-*.mat'):
        yield (__test, infile)
    pass

def test_tempo():
    def __test(infile):
        DATA    = load(infile)

        # Estimate tempo from the given onset envelope
        tempo   = librosa.beat.onset_estimate_bpm(  DATA['onsetenv'][0], 
                                                    120.0,  # starting bpm
                                                    8000 / 32)
<commit_msg>updated onset strength unit test<commit_after>#!/usr/bin/env python
# CREATED:2013-03-11 18:14:30 by <NAME> <<EMAIL>>
#  unit tests for librosa.beat


import librosa, numpy

from testLibrosaCore import files, load

def test_onset_strength():

    def __test(infile):
        DATA    = load(infile)

        # Compute onset envelope using the same spectrogram
        onsets  = librosa.onset.onset_strength(y=None, sr=8000, S=DATA['D'])

        assert numpy.allclose(onsets, DATA['onsetenv'][0])

        pass

    for infile in files('data/beat-onset-*.mat'):
        yield (__test, infile)
    pass

def test_tempo():
    def __test(infile):
        DATA    = load(infile)

        # Estimate tempo from the given onset envelope
        tempo   = librosa.beat.onset_estimate_bpm(  DATA['onsetenv'][0], 
                                                    120.0,  # starting bpm
                                                    8000 / 32)

{'fraction_non_alphanumeric': 0.1044776119402985, 'fraction_numerical': 0.031982942430703626, 'mean_word_length': 1.9746434231378764, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5867507', 'n_tokens_mistral': 641, 'n_tokens_neox': 558, 'n_words': 143}