Changeset 5a7e2c3 for python/tests


Ignore:
Timestamp:
Jul 10, 2015, 1:51:25 AM (9 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
4615886a
Parents:
efa62ce
Message:

ext/py-musicutils.c: add level_lin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_musicutils.py

    refa62ce r5a7e2c3  
    22
    33from numpy.testing import TestCase
    4 from numpy.testing.utils import assert_almost_equal
    5 from aubio import window
     4from numpy.testing.utils import assert_equal, assert_almost_equal
     5from numpy import cos, arange
     6from math import pi
     7
     8from aubio import window, level_lin
     9
     10from aubio import fvec
    611
    712class aubio_window(TestCase):
     
    2732
    2833    def test_compute_hanning_1024(self):
    29         from numpy import cos, arange
    30         from math import pi
    3134        size = 1024
    3235        aubio_window = window("hanning", size)
     
    3437        assert_almost_equal(aubio_window, numpy_window)
    3538
     39class aubio_level_lin(TestCase):
     40    def test_accept_fvec(self):
     41        level_lin(fvec(1024))
     42
     43    def test_fail_not_fvec(self):
     44        try:
     45            level_lin("default")
     46        except ValueError, e:
     47            pass
     48        else:
     49            self.fail('non-number input phase does not raise a TypeError')
     50
     51    def test_zeros_is_zeros(self):
     52        assert_equal(level_lin(fvec(1024)), 0.)
     53
     54    def test_minus_ones_is_one(self):
     55        from numpy import ones
     56        assert_equal(level_lin(-ones(1024, dtype="float32")), 1.)
     57
    3658if __name__ == '__main__':
    3759    from unittest import main
Note: See TracChangeset for help on using the changeset viewer.