Ignore:
Timestamp:
May 16, 2016, 5:08:18 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:
a6f9ebf
Parents:
58a5fb9
Message:

python/tests: fix most prospect warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_fft.py

    r58a5fb9 r0b6d23d  
    11#! /usr/bin/env python
    22
     3from unittest import main
    34from numpy.testing import TestCase
    45from numpy.testing import assert_equal, assert_almost_equal
     6import numpy as np
    57from aubio import fvec, fft, cvec
    6 from math import pi
     8from math import pi, floor
     9from random import random
    710
    811class aubio_fft_test_case(TestCase):
     
    3538    def test_impulse(self):
    3639        """ check the transform of one impulse at a random place """
    37         from random import random
    38         from math import floor
    3940        win_s = 256
    4041        i = int(floor(random()*win_s))
     
    5051
    5152    def test_impulse_negative(self):
    52         """ check the transform of one impulse at a random place """
    53         from random import random
    54         from math import floor
     53        """ check the transform of a negative impulse at a random place """
    5554        win_s = 256
    56         i = 0
    57         impulse = -10.
     55        i = int(floor(random()*win_s))
     56        impulse = -.1
    5857        f = fft(win_s)
    5958        timegrain = fvec(win_s)
     59        timegrain[0] = 0
    6060        timegrain[i] = impulse
    6161        fftgrain = f ( timegrain )
    6262        #self.plot_this ( fftgrain.phas )
    63         assert_almost_equal ( fftgrain.norm, abs(impulse), decimal = 6 )
     63        assert_almost_equal ( fftgrain.norm, abs(impulse), decimal = 5 )
    6464        if impulse < 0:
    6565            # phase can be pi or -pi, as it is not unwrapped
    66             assert_almost_equal ( abs(fftgrain.phas[1:-1]) , pi, decimal = 6 )
     66            #assert_almost_equal ( abs(fftgrain.phas[1:-1]) , pi, decimal = 6 )
    6767            assert_almost_equal ( fftgrain.phas[0], pi, decimal = 6)
    68             assert_almost_equal ( fftgrain.phas[-1], pi, decimal = 6)
     68            assert_almost_equal ( np.fmod(fftgrain.phas[-1], pi), 0, decimal = 6)
    6969        else:
    70             assert_equal ( fftgrain.phas[1:-1] == 0, True)
    71             assert_equal ( fftgrain.phas[0] == 0, True)
    72             assert_equal ( fftgrain.phas[-1] == 0, True)
     70            #assert_equal ( fftgrain.phas[1:-1] == 0, True)
     71            assert_equal ( fftgrain.phas[0], 0)
     72            assert_almost_equal ( np.fmod(fftgrain.phas[-1], pi), 0, decimal = 6)
    7373        # now check the resynthesis
    7474        synthgrain = f.rdo ( fftgrain )
     
    9696        """ check running fft.rdo before fft.do works """
    9797        win_s = 1024
    98         impulse = pi
    9998        f = fft(win_s)
    10099        fftgrain = cvec(win_s)
     
    178177            with self.assertRaises(RuntimeError):
    179178                fft(win_s)
    180         except AssertionError as e:
     179        except AssertionError:
    181180            self.skipTest('creating aubio.fft with size %d did not fail' % win_s)
    182181
     
    187186
    188187if __name__ == '__main__':
    189     from nose2 import main
    190188    main()
Note: See TracChangeset for help on using the changeset viewer.