Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -4,20 +4,25 @@ from unittest import main · 3 unmodified lines | |||
| 4 | from numpy.testing import TestCase | 4 | from numpy.testing import TestCase |
| 5 | from numpy.testing import assert_equal, assert_almost_equal | 5 | from numpy.testing import assert_equal, assert_almost_equal |
| 6 | from _tools import assert_warns | 6 | from _tools import assert_warns |
| 7 | from utils import is32bit | ||
| 7 | import numpy as np | 8 | import numpy as np |
| 8 | import aubio | 9 | import aubio |
| 9 | 10 | ||
| 10 | from aubio import hztomel, meltohz | 11 | from aubio import hztomel, meltohz |
| 11 | from aubio import hztomel_htk, meltohz_htk | 12 | from aubio import hztomel_htk, meltohz_htk |
| 12 | 13 | ||
| 13 | |||
| 14 | class aubio_hztomel_test_case(TestCase): | 14 | class aubio_hztomel_test_case(TestCase): |
| 15 | 15 | ||
| 16 | def test_hztomel(self): | 16 | def test_hztomel(self): |
| 17 | assert_equal(hztomel(0.), 0.) | 17 | assert_equal(hztomel(0.), 0.) |
| 18 | assert_almost_equal(hztomel(400. / 3.), 2., decimal=5) | 18 | assert_almost_equal(hztomel(400. / 3.), 2., decimal=5) |
| 19 | assert_almost_equal(hztomel(1000. / 3), 5.) | 19 | assert_almost_equal(hztomel(1000. / 3), 5.) |
| 20 | assert_equal(hztomel(200.), 3.) | 20 | # on 32bit, some of these tests fails unless compiling with -ffloat-store |
| 21 | try: | ||
| 22 | assert_equal(hztomel(200.), 3.) | ||
| 23 | except AssertionError: | ||
| 24 | if not is32bit(): raise | ||
| 25 | assert_almost_equal(hztomel(200.), 3., decimal=5) | ||
| 21 | assert_almost_equal(hztomel(1000.), 15) | 26 | assert_almost_equal(hztomel(1000.), 15) |
| 22 | assert_almost_equal(hztomel(6400), 42, decimal=5) | 27 | assert_almost_equal(hztomel(6400), 42, decimal=5) |
| 23 | assert_almost_equal(hztomel(40960), 69, decimal=5) | 28 | assert_almost_equal(hztomel(40960), 69, decimal=5) |
| @@ -28,7 +33,11 @@ class aubio_hztomel_test_case(TestCase): · 4 unmodified lines | |||
| 28 | def test_meltohz(self): | 33 | def test_meltohz(self): |
| 29 | assert_equal(meltohz(0.), 0.) | 34 | assert_equal(meltohz(0.), 0.) |
| 30 | assert_almost_equal(meltohz(2), 400. / 3., decimal=4) | 35 | assert_almost_equal(meltohz(2), 400. / 3., decimal=4) |
| 31 | assert_equal(meltohz(3.), 200.) | 36 | try: |
| 37 | assert_equal(meltohz(3.), 200.) | ||
| 38 | except AssertionError: | ||
| 39 | if not is32bit(): raise | ||
| 40 | assert_almost_equal(meltohz(3.), 200., decimal=5) | ||
| 32 | assert_almost_equal(meltohz(5), 1000. / 3., decimal=4) | 41 | assert_almost_equal(meltohz(5), 1000. / 3., decimal=4) |
| 33 | assert_almost_equal(meltohz(15), 1000., decimal=4) | 42 | assert_almost_equal(meltohz(15), 1000., decimal=4) |
| 34 | assert_almost_equal(meltohz(42), 6400., decimal=2) | 43 | assert_almost_equal(meltohz(42), 6400., decimal=2) |