From: Paul Brossier Date: Tue, 5 Mar 2013 07:55:29 +0000 (-0500) Subject: tests/python/: removed old python tests X-Git-Tag: 0.4.0-beta1~253 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=208336b59c75969bf945e0c2dc048daefba0f5b1;p=aubio.git tests/python/: removed old python tests --- diff --git a/python/tests/test_hist.py.old b/python/tests/test_hist.py.old new file mode 100644 index 00000000..baefa409 --- /dev/null +++ b/python/tests/test_hist.py.old @@ -0,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() diff --git a/python/tests/test_zero_crossing_rate.py.old b/python/tests/test_zero_crossing_rate.py.old new file mode 100644 index 00000000..1b1d9111 --- /dev/null +++ b/python/tests/test_zero_crossing_rate.py.old @@ -0,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() diff --git a/tests/python/aubiomodule.py b/tests/python/aubiomodule.py deleted file mode 100644 index cc2445c1..00000000 --- a/tests/python/aubiomodule.py +++ /dev/null @@ -1,14 +0,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() diff --git a/tests/python/examples/aubionotes.py b/tests/python/examples/aubionotes.py deleted file mode 100644 index 5d181507..00000000 --- a/tests/python/examples/aubionotes.py +++ /dev/null @@ -1,40 +0,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() diff --git a/tests/python/localaubio.py b/tests/python/localaubio.py deleted file mode 100644 index e09bcac2..00000000 --- a/tests/python/localaubio.py +++ /dev/null @@ -1,30 +0,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 * diff --git a/tests/python/run_all_tests b/tests/python/run_all_tests deleted file mode 100755 index 68caefb2..00000000 --- a/tests/python/run_all_tests +++ /dev/null @@ -1,22 +0,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() diff --git a/tests/python/src/__init__.py b/tests/python/src/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/python/src/onset/__init__.py b/tests/python/src/onset/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/python/src/pitch/__init__.py b/tests/python/src/pitch/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/python/src/spectral/__init__.py b/tests/python/src/spectral/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/python/src/temporal/__init__.py b/tests/python/src/temporal/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/python/src/temporal/zero_crossing_rate.py b/tests/python/src/temporal/zero_crossing_rate.py deleted file mode 100644 index 98ad13c0..00000000 --- a/tests/python/src/temporal/zero_crossing_rate.py +++ /dev/null @@ -1,53 +0,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() diff --git a/tests/python/src/utils/__init__.py b/tests/python/src/utils/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/python/src/utils/hist.py b/tests/python/src/utils/hist.py deleted file mode 100644 index 905235a5..00000000 --- a/tests/python/src/utils/hist.py +++ /dev/null @@ -1,72 +0,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() diff --git a/tests/python/template.py b/tests/python/template.py deleted file mode 100644 index 687189a6..00000000 --- a/tests/python/template.py +++ /dev/null @@ -1,40 +0,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) diff --git a/tests/python/unittest_examples.py b/tests/python/unittest_examples.py deleted file mode 100644 index 740c7312..00000000 --- a/tests/python/unittest_examples.py +++ /dev/null @@ -1,31 +0,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()