ref: 208336b59c75969bf945e0c2dc048daefba0f5b1
parent: f50e53431107ada627c9fef344fa3a23155368ea
author: Paul Brossier <piem@piem.org>
date: Mon Mar 4 21:55:29 EST 2013
tests/python/: removed old python tests
--- /dev/null
+++ b/python/tests/test_hist.py.old
@@ -1,0 +1,74 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+from aubio import fvec, digital_filter
+import random
+
+buf_size = 2048
+channels = 1
+flow = float(random.randint(0, 100) + random.random())
+fhig = float(random.randint(100, 1000) + random.random())
+
+nelems = 1000
+
+class hist_test_case(TestCase):
+
+ def setUp(self):
+ self.o = new_aubio_hist(flow, fhig, nelems, channels)
+
+ def tearDown(self):
+ del_aubio_hist(self.o)
+
+ def test_hist(self):
+ """ create and delete hist """
+ pass
+
+ def test_hist_zeroes(self):
+ """ test hist on zeroes """
+ input = new_fvec(buf_size, channels)
+ aubio_hist_do_notnull(self.o, input)
+ aubio_hist_weight(self.o)
+ self.assertEqual(0., aubio_hist_mean(self.o))
+ del_fvec(input)
+
+ def test_hist_impulse_top(self):
+ """ test hist on impulse (top - 1.) """
+ """ this returns 1./nelems because 1 element is in the range """
+ input = new_fvec(buf_size, channels)
+ constant = fhig - 1.
+ fvec_write_sample(input,constant,0,0)
+ aubio_hist_do_notnull(self.o, input)
+ self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
+ del_fvec(input)
+
+ def test_hist_impulse_over(self):
+ """ test hist on impulse (top + 1.) """
+ """ this returns 0 because constant is out of range """
+ input = new_fvec(buf_size, channels)
+ constant = fhig + 1.
+ fvec_write_sample(input,constant,0,0)
+ aubio_hist_do_notnull(self.o, input)
+ self.assertCloseEnough(0., aubio_hist_mean(self.o))
+ del_fvec(input)
+
+ def test_hist_impulse_bottom(self):
+ """ test hist on constant near lower limit """
+ """ this returns 1./nelems because 1 element is in the range """
+ input = new_fvec(buf_size, channels)
+ constant = flow + 1.
+ fvec_write_sample(input,constant,0,0)
+ aubio_hist_do_notnull(self.o, input)
+ self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
+ del_fvec(input)
+
+ def test_hist_impulse_under(self):
+ """ test hist on constant under lower limit """
+ """ this returns 0 because constant is out of range """
+ vec_in = fvec(buf_size)
+ constant = flow - 1.
+ vec_in[0] = constant
+ aubio_hist_do_notnull(self.o, input)
+ self.assertCloseEnough(0., aubio_hist_mean(self.o))
+ del_fvec(input)
+
+if __name__ == '__main__': unittest.main()
--- /dev/null
+++ b/python/tests/test_zero_crossing_rate.py.old
@@ -1,0 +1,56 @@
+from aubio import zero_crossing_rate
+
+#! /usr/bin/env python
+
+from numpy.testing import TestCase
+
+buf_size = 2048
+channels = 1
+
+class zero_crossing_rate_test_case(TestCase):
+
+ def setUp(self):
+ self.vector = new_fvec(buf_size, channels)
+
+ def tearDown(self):
+ del_fvec(self.vector)
+
+ def test(self):
+ """ create and delete fvec """
+ pass
+
+ def test_zeroes(self):
+ """ check zero crossing rate on a buffer of 0. """
+ self.assertEqual(0., zero_crossing_rate(self.vector))
+
+ def test_ones(self):
+ """ check zero crossing rate on a buffer of 1. """
+ for index in range(buf_size):
+ for channel in range(channels):
+ fvec_write_sample(self.vector, 1., channel, index)
+ self.assertEqual(0., zero_crossing_rate(self.vector))
+
+ def test_impulse(self):
+ """ check zero crossing rate on a buffer with an impulse """
+ fvec_write_sample(self.vector, 1., 0, buf_size / 2)
+ self.assertEqual(0., zero_crossing_rate(self.vector))
+
+ def test_negative_impulse(self):
+ """ check zero crossing rate on a buffer with a negative impulse """
+ fvec_write_sample(self.vector, -1., 0, buf_size / 2)
+ self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
+
+ def test_single(self):
+ """ check zero crossing rate on single crossing """
+ fvec_write_sample(self.vector, +1., 0, buf_size / 2 - 1)
+ fvec_write_sample(self.vector, -1., 0, buf_size / 2)
+ self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
+
+ def test_single_with_gap(self):
+ """ check zero crossing rate on single crossing with a gap"""
+ fvec_write_sample(self.vector, +1., 0, buf_size / 2 - 2)
+ fvec_write_sample(self.vector, -1., 0, buf_size / 2)
+ self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
+
+if __name__ == '__main__':
+ unittest.main()
--- a/tests/python/aubiomodule.py
+++ /dev/null
@@ -1,14 +1,0 @@
-import unittest
-
-class aubiomodule_test_case(unittest.TestCase):
-
- def test_aubio(self):
- """ try importing aubio module """
- import aubio
-
- def test_aubiowrapper(self):
- """ try importing aubio.aubiowrapper module """
- from aubio import aubiowrapper
-
-if __name__ == '__main__':
- unittest.main()
--- a/tests/python/examples/aubionotes.py
+++ /dev/null
@@ -1,40 +1,0 @@
-from template import *
-
-class aubionotes_test_case(program_test_case):
-
- import os.path
- filename = os.path.join('..','..','sounds','woodblock.aiff')
- progname = os.path.join('..','..','examples','aubionotes')
-
- def test_aubionotes(self):
- """ test aubionotes with default parameters """
- self.getOutput()
- # FIXME: useless check
- self.assertEqual(len(self.output.split('\n')), 1)
- self.assertEqual(float(self.output.strip()), 0.017415)
-
- def test_aubionotes_verbose(self):
- """ test aubionotes with -v parameter """
- self.command += " -v "
- self.getOutput()
- # FIXME: loose checking: make sure at least 8 lines are printed
- assert len(self.output) >= 8
-
- def test_aubionotes_devnull(self):
- """ test aubionotes on /dev/null """
- self.filename = "/dev/null"
- # exit status should not be 0
- self.getOutput(expected_status = 256)
- # and there should be an error message
- assert len(self.output) > 0
- # that looks like this
- #output_lines = self.output.split('\n')
- #for line in output_lines:
- # print line
-
-mode_names = ["yinfft", "yin", "fcomb", "mcomb", "schmitt"]
-for name in mode_names:
- exec("class aubionotes_test_case_" + name + "(aubionotes_test_case):\n\
- options = \" -p " + name + " \"")
-
-if __name__ == '__main__': unittest.main()
--- a/tests/python/localaubio.py
+++ /dev/null
@@ -1,30 +1,0 @@
-
-# add ${src}/python and ${src}/python/aubio/.libs to python path
-# so the script is runnable from a compiled source tree.
-
-try:
- from aubio.aubiowrapper import *
-except ImportError:
- try:
- import os
- import sys
- cur_dir = os.path.dirname(__file__)
- sys.path.append(os.path.join(cur_dir,'..','..','python'))
- # autotools places
- sys.path.append(os.path.join(cur_dir,'..','..','python','aubio'))
- sys.path.append(os.path.join(cur_dir,'..','..','python','aubio','.libs'))
- # waf places
- sys.path.append(os.path.join(cur_dir,'..','..','build', 'default', 'swig'))
- sys.path.append(os.path.join(cur_dir,'..','..','build', 'default', 'python','aubio'))
- from aubiowrapper import *
- except ImportError:
- raise
-else:
- raise ImportError, \
- """
- The aubio module could be imported BEFORE adding the source directory to
- your path. Make sure you NO other version of the python aubio module is
- installed on your system.
- """
-
-from template import *
--- a/tests/python/run_all_tests
+++ /dev/null
@@ -1,22 +1,0 @@
-#! /usr/bin/python
-
-import unittest
-
-from glob import glob
-def list_of_test_files(path):
- matches = glob(path)
- if not matches: print "WARNING: no matches for %s" % path
- return [i.split('.')[0].replace('/','.') for i in matches]
-
-modules_to_test = []
-modules_to_test += ['localaubio']
-modules_to_test += list_of_test_files('src/*.py')
-modules_to_test += list_of_test_files('src/*/*.py')
-modules_to_test += list_of_test_files('examples/aubio*.py')
-modules_to_test += list_of_test_files('*.py')
-
-if __name__ == '__main__':
- for module in modules_to_test:
- if module != 'run_all_tests': # (not actually needed)
- exec('from %s import *' % module)
- unittest.main()
--- a/tests/python/src/temporal/zero_crossing_rate.py
+++ /dev/null
@@ -1,53 +1,0 @@
-from template import aubio_unit_template
-from localaubio import *
-
-buf_size = 2048
-channels = 1
-
-class zero_crossing_rate_unit(unittest.TestCase):
-
- def setUp(self):
- self.vector = new_fvec(buf_size, channels)
-
- def tearDown(self):
- del_fvec(self.vector)
-
- def test(self):
- """ create and delete fvec """
- pass
-
- def test_zeroes(self):
- """ check zero crossing rate on a buffer of 0. """
- self.assertEqual(0., aubio_zero_crossing_rate(self.vector))
-
- def test_ones(self):
- """ check zero crossing rate on a buffer of 1. """
- for index in range(buf_size):
- for channel in range(channels):
- fvec_write_sample(self.vector, 1., channel, index)
- self.assertEqual(0., aubio_zero_crossing_rate(self.vector))
-
- def test_impulse(self):
- """ check zero crossing rate on a buffer with an impulse """
- fvec_write_sample(self.vector, 1., 0, buf_size / 2)
- self.assertEqual(0., aubio_zero_crossing_rate(self.vector))
-
- def test_negative_impulse(self):
- """ check zero crossing rate on a buffer with a negative impulse """
- fvec_write_sample(self.vector, -1., 0, buf_size / 2)
- self.assertEqual(2./buf_size, aubio_zero_crossing_rate(self.vector))
-
- def test_single(self):
- """ check zero crossing rate on single crossing """
- fvec_write_sample(self.vector, +1., 0, buf_size / 2 - 1)
- fvec_write_sample(self.vector, -1., 0, buf_size / 2)
- self.assertEqual(2./buf_size, aubio_zero_crossing_rate(self.vector))
-
- def test_single_with_gap(self):
- """ check zero crossing rate on single crossing with a gap"""
- fvec_write_sample(self.vector, +1., 0, buf_size / 2 - 2)
- fvec_write_sample(self.vector, -1., 0, buf_size / 2)
- self.assertEqual(2./buf_size, aubio_zero_crossing_rate(self.vector))
-
-if __name__ == '__main__':
- unittest.main()
--- a/tests/python/src/utils/hist.py
+++ /dev/null
@@ -1,72 +1,0 @@
-from template import aubio_unit_template
-from localaubio import *
-import random
-
-buf_size = 2048
-channels = 1
-flow = float(random.randint(0, 100) + random.random())
-fhig = float(random.randint(100, 1000) + random.random())
-
-nelems = 1000
-
-class hist_unit(aubio_unit_template):
-
- def setUp(self):
- self.o = new_aubio_hist(flow, fhig, nelems, channels)
-
- def tearDown(self):
- del_aubio_hist(self.o)
-
- def test_hist(self):
- """ create and delete hist """
- pass
-
- def test_hist_zeroes(self):
- """ test hist on zeroes """
- input = new_fvec(buf_size, channels)
- aubio_hist_do_notnull(self.o, input)
- aubio_hist_weight(self.o)
- self.assertEqual(0., aubio_hist_mean(self.o))
- del_fvec(input)
-
- def test_hist_impulse_top(self):
- """ test hist on impulse (top - 1.) """
- """ this returns 1./nelems because 1 element is in the range """
- input = new_fvec(buf_size, channels)
- constant = fhig - 1.
- fvec_write_sample(input,constant,0,0)
- aubio_hist_do_notnull(self.o, input)
- self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
- del_fvec(input)
-
- def test_hist_impulse_over(self):
- """ test hist on impulse (top + 1.) """
- """ this returns 0 because constant is out of range """
- input = new_fvec(buf_size, channels)
- constant = fhig + 1.
- fvec_write_sample(input,constant,0,0)
- aubio_hist_do_notnull(self.o, input)
- self.assertCloseEnough(0., aubio_hist_mean(self.o))
- del_fvec(input)
-
- def test_hist_impulse_bottom(self):
- """ test hist on constant near lower limit """
- """ this returns 1./nelems because 1 element is in the range """
- input = new_fvec(buf_size, channels)
- constant = flow + 1.
- fvec_write_sample(input,constant,0,0)
- aubio_hist_do_notnull(self.o, input)
- self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
- del_fvec(input)
-
- def test_hist_impulse_under(self):
- """ test hist on constant under lower limit """
- """ this returns 0 because constant is out of range """
- input = new_fvec(buf_size, channels)
- constant = flow - 1.
- fvec_write_sample(input,constant,0,0)
- aubio_hist_do_notnull(self.o, input)
- self.assertCloseEnough(0., aubio_hist_mean(self.o))
- del_fvec(input)
-
-if __name__ == '__main__': unittest.main()
--- a/tests/python/template.py
+++ /dev/null
@@ -1,40 +1,0 @@
-import unittest
-from commands import getstatusoutput
-from numpy import array
-
-class aubio_unit_template(unittest.TestCase):
- """ a class derivated from unittest.TestCase """
-
- def assertCloseEnough(self, first, second, places=5, msg=None):
- """Fail if the two objects are unequal as determined by their
- *relative* difference rounded to the given number of decimal places
- (default 7) and comparing to zero.
- """
- if round(first, places) == 0:
- if round(second-first, places) != 0:
- raise self.failureException, \
- (msg or '%r != %r within %r places' % (first, second, places))
- else:
- if round((second-first)/first, places) != 0:
- raise self.failureException, \
- (msg or '%r != %r within %r places' % (first, second, places))
-
-class program_test_case(unittest.TestCase):
-
- filename = "/dev/null"
- progname = "UNDEFINED"
- command = ""
- options = ""
-
- def getOutput(self, expected_status = 0):
- self.command = self.progname + ' -i ' + self.filename + self.command
- self.command += self.options
- [self.status, self.output] = getstatusoutput(self.command)
- if expected_status != -1:
- assert self.status == expected_status, \
- "expected status was %s, got %s\nOutput was:\n%s\n command was %s" % \
- (expected_status, self.status, self.output, self.command)
-
-def array_from_text_file(filename, dtype = 'float'):
- return array([line.split() for line in open(filename).readlines()],
- dtype = dtype)
--- a/tests/python/unittest_examples.py
+++ /dev/null
@@ -1,31 +1,0 @@
-import unittest
-
-# this file is just to illustrates and test some of the unittest module
-# functionalities.
-
-class raise_test_case(unittest.TestCase):
- def test_assertEqual(self):
- """ check assertEqual returns AssertionError """
- try:
- self.assertEqual(0.,1.)
- except AssertionError:
- pass
- else:
- fail('expected an AssertionError exception')
-
- def test_assertAlmostEqual(self):
- """ check assertAlmostEqual returns AssertionError """
- try:
- self.assertAlmostEqual(0.,1.)
- except AssertionError:
- pass
- else:
- fail('expected an AssertionError exception')
-
- def test_assertRaises(self):
- """ check assertRaises works as expected """
- self.assertRaises(AssertionError, self.assertEqual, 0.,1.)
- self.assertRaises(AssertionError, self.assertAlmostEqual, 0.,1.,1)
-
-if __name__ == '__main__':
- unittest.main()