def test_beat():

    y, sr = librosa.load(__EXAMPLE_FILE)

    hop_length = 512

    onset_env = librosa.onset.onset_strength(y=y, sr=sr, hop_length=hop_length)

    def __test(with_audio, with_tempo, start_bpm, bpm, trim, tightness):
    
        if with_audio:
            _y = y
            _ons = None
        else:
            _y = None
            _ons = onset_env

        tempo, beats = librosa.beat.beat_track(y=_y,
                                               sr=sr,
                                               onset_envelope=_ons,
                                               hop_length=hop_length,
                                               start_bpm=start_bpm,
                                               tightness=tightness,
                                               trim=trim,
                                               bpm=bpm)

        assert tempo >= 0

        if len(beats) > 0:
            assert beats.min() >= 0
            assert beats.max() <= len(onset_env)

    for with_audio in [False, True]:
        for with_tempo in [False, True]:
            for trim in [False, True]:
                for start_bpm in [-20, 0, 60, 120, 240]:
                    for bpm in [-20, 0, None, 150, 360]:
                        for tightness in [0, 100, 10000]:

                            if (tightness <= 0 or
                                (bpm is not None and bpm <= 0) or
                                (start_bpm is not None and bpm is None and start_bpm <= 0)):

                                tf = raises(librosa.ParameterError)(__test)
                            else:
                                tf = __test
                            yield (tf, with_audio, with_tempo,
                                   start_bpm, bpm, trim, tightness)


# Beat tracking regression test is no longer enabled due to librosa's
# corrections
dataset/ETHPy150Open bmcfee/librosa/tests/test_beat.py/test_beat/original