<commit_before>#!/usr/bin/env python
# CREATED:2014-12-29 10:52:23 by <NAME> <<EMAIL>>
# unit tests for ill-formed inputs

# Disable cache
import os
try:
    os.environ.pop('LIBROSA_CACHE_DIR')
except:
    pass

import numpy as np
import librosa
from nose.tools import raises


@raises(ValueError)
def test_mono_valid_stereo():
    '''valid_audio: mono=True,  y.ndim==2'''
    y = np.random.randn(2, 1000)
    librosa.util.valid_audio(y, mono=True)


def test_valid_stereo():
    '''valid_audio: mono=False, y.ndim==2'''
    y = np.random.randn(2, 1000)
    librosa.util.valid_audio(y, mono=False)


def test_valid_mono():
    '''valid_audio: mono=True,  y.ndim==1'''
    y = np.random.randn(1000)
    librosa.util.valid_audio(y, mono=True)


@raises(ValueError)
def test_valid_audio_type():
    '''valid_audio: list input'''
    y = list(np.random.randn(1000))
    librosa.util.valid_audio(y)


@raises(ValueError)
def test_valid_audio_nan():
    '''valid_audio: NaN'''
    y = np.random.randn(1000)
    y[10] = np.NaN
    librosa.util.valid_audio(y)


@raises(ValueError)
def test_valid_audio_inf():
    '''valid_audio: Inf'''
    y = np.random.randn(1000)
    y[10] = np.inf
    librosa.util.valid_audio(y)
<commit_msg>added tests to frame<commit_after>#!/usr/bin/env python
# CREATED:2014-12-29 10:52:23 by B<NAME> <<EMAIL>>
# unit tests for ill-formed inputs

# Disable cache
import os
try:
    os.environ.pop('LIBROSA_CACHE_DIR')
except:
    pass

import numpy as np
import librosa
from nose.tools import raises


@raises(ValueError)
def test_mono_valid_stereo():
    '''valid_audio: mono=True,  y.ndim==2'''
    y = np.zeros((2, 1000))
    librosa.util.valid_audio(y, mono=True)


def test_valid_stereo_or_mono():
    '''valid_audio: mono=False, y.ndim==1'''
    y = np.zeros(1000)
    librosa.util.valid_audio(y, mono=False)


def test_valid_mono():
    '''valid_audio: mono=True,  y.ndim==1'''
    y = np.zeros(1000)
    librosa.util.valid_audio(y, mono=True)


def test_valid_stereo():
    '''valid_audio: mono=False, y.ndim==2'''
    y = np.zeros((2, 1000))
    librosa.util.valid_audio(y, mono=False)


@raises(ValueError)
def test_valid_audio_type():
    '''valid_audio: list input'''
    y = list(np.zeros(1000))
    librosa.util.valid_audio(y)


@raises(ValueError)
def test_valid_audio_nan():
    '''valid_audio: NaN'''
    y = np.zeros(1000)
    y[10] = np.NaN
    librosa.util.valid_audio(y)


@raises(ValueError)
def test_valid_audio_inf():
    '''valid_audio: Inf'''
    y = np.zeros(1000)
    y[10] = np.inf
    librosa.util.valid_audio(y)


@raises(ValueError)
def test_frame_hop():
    '''frame: hop_length=0'''
    y = np.zeros(128)
    librosa.util.frame(y, frame_length=10, hop_length=0)


@raises(ValueError)
def test_frame_discontiguous():
    '''frame: discontiguous input'''
    y = np.zeros((128, 2)).T
    librosa.util.frame(y[0], frame_length=64, hop_length=64)


def test_frame_contiguous():
    '''frame: discontiguous input'''
    y = np.zeros((2, 128))
    librosa.util.frame(y[0], frame_length=64, hop_length=64)


@raises(ValueError)
def test_frame_size():
    '''frame: len(y) == 128, frame_length==256, hop_length=128'''
    y = np.zeros(64)
    librosa.util.frame(y, frame_length=256, hop_length=128)
{'fraction_non_alphanumeric': 0.16132017273288093, 'fraction_numerical': 0.043491671807526215, 'mean_word_length': 4.155802861685214, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2935949', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1292, 'n_words': 236}