Changeset 42f1cf14 for tests


Ignore:
Timestamp:
May 18, 2008, 3:23:11 AM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
bf9d8a6
Parents:
4ecfee9
Message:

tests/python/src/utils/hist.py: update existing test cases, add two more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/python/src/utils/hist.py

    r4ecfee9 r42f1cf14  
    11import unittest
     2import random
    23
    34from template import aubio_unit_template
     
    67buf_size = 2048
    78channels = 1
    8 flow = 0.
    9 fhig = 100.
     9flow = float(random.randint(0, 100) + random.random())
     10fhig = float(random.randint(100, 1000) + random.random())
    1011
    1112nelems = 1000
     
    1415
    1516  def setUp(self):
     17    print flow, fhig
    1618    self.o = new_aubio_hist(flow, fhig, nelems, channels)
    1719
     
    3133    del_fvec(input)
    3234
    33   def test_hist_impulse(self):
    34     """ test hist on impulse """
     35  def test_hist_impulse_top(self):
     36    """ test hist on impulse (top - 1.) """
     37    """ this returns 1./nelems because 1 element is in the range """
    3538    input = new_fvec(buf_size, channels)
    3639    constant = fhig - 1.
     
    4043    del_fvec(input)
    4144
    42   def test_hist_impulse2(self):
    43     """ test hist on impulse """
     45  def test_hist_impulse_over(self):
     46    """ test hist on impulse (top + 1.) """
     47    """ this returns 0 because constant is out of range """
    4448    input = new_fvec(buf_size, channels)
    4549    constant = fhig + 1.
     50    fvec_write_sample(input,constant,0,0)
     51    aubio_hist_do_notnull(self.o, input)
     52    self.assertCloseEnough(0., aubio_hist_mean(self.o))
     53    del_fvec(input)
     54
     55  def test_hist_impulse_bottom(self):
     56    """ test hist on constant near lower limit """
     57    """ this returns 1./nelems because 1 element is in the range """
     58    input = new_fvec(buf_size, channels)
     59    constant = flow + 1.
    4660    fvec_write_sample(input,constant,0,0)
    4761    aubio_hist_do_notnull(self.o, input)
     
    4963    del_fvec(input)
    5064
     65  def test_hist_impulse_under(self):
     66    """ test hist on constant under lower limit """
     67    """ this returns 0 because constant is out of range """
     68    input = new_fvec(buf_size, channels)
     69    constant = flow - 1.
     70    fvec_write_sample(input,constant,0,0)
     71    aubio_hist_do_notnull(self.o, input)
     72    self.assertCloseEnough(0., aubio_hist_mean(self.o))
     73    del_fvec(input)
     74
    5175if __name__ == '__main__': unittest.main()
Note: See TracChangeset for help on using the changeset viewer.