<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import numpy as np
import resampy

from nose.tools import eq_, raises


def test_shape():

    def __test(axis, sr_orig, sr_new, X):

        Y = resampy.resample(X, sr_orig, sr_new, axis=axis)

        target_shape = list(X.shape)
        target_shape[axis] = target_shape[axis] * sr_new // sr_orig

        eq_(target_shape, list(Y.shape))

    sr_orig = 100
    X = np.random.randn(sr_orig, sr_orig, sr_orig)

    for axis in [0, 1, 2]:
        yield __test, axis, sr_orig, sr_orig // 2, X<commit_msg>added more test coverage<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import numpy as np
import resampy

from nose.tools import eq_, raises


def test_shape():

    def __test(axis, sr_orig, sr_new, X):

        Y = resampy.resample(X, sr_orig, sr_new, axis=axis)

        target_shape = list(X.shape)
        target_shape[axis] = target_shape[axis] * sr_new // sr_orig

        eq_(target_shape, list(Y.shape))

    sr_orig = 100
    X = np.random.randn(sr_orig, sr_orig, sr_orig)

    for axis in [0, 1, 2]:
        yield __test, axis, sr_orig, sr_orig // 2, X


def test_bad_sr():

    x = np.zeros(100)
    yield raises(ValueError)(resampy.resample), x, 100, 0
    yield raises(ValueError)(resampy.resample), x, 100, -1
    yield raises(ValueError)(resampy.resample), x, 0, 100
    yield raises(ValueError)(resampy.resample), x, -1, 100



def test_bad_rolloff():

    @raises(ValueError)
    def __test(rolloff):

        x = np.zeros(100)
        resampy.resample(x, 100, 50, rolloff=rolloff)
    
    yield __test, -1
    yield __test, 1.5
{'fraction_non_alphanumeric': 0.12936848559166156, 'fraction_numerical': 0.028203556100551808, 'mean_word_length': 2.8949880668257757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7417669', 'n_tokens_mistral': 677, 'n_tokens_neox': 596, 'n_words': 151}