Showing the changes to python (6 of 6 files). Show all
Unified · Split
| @@ -5,7 +5,7 @@ from numpy.testing import assert_equal, assert_almost_equal · 4 unmodified lines | ||
| 5 | 5 | from numpy import random |
| 6 | 6 | from math import pi |
| 7 | 7 | from numpy import array |
| 8 | −from aubio import cvec, filterbank | |
| 8 | +from aubio import cvec, filterbank, float_type | |
| 9 | 9 | from utils import array_from_text_file |
| 10 | 10 | |
| 11 | 11 | class aubio_filterbank_test_case(TestCase): |
| @@ -16,7 +16,7 @@ class aubio_filterbank_test_case(TestCase): · 4 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | def test_set_coeffs(self): |
| 18 | 18 | f = filterbank(40, 512) |
| 19 | − r = random.random([40, int(512 / 2) + 1]).astype('float32') | |
| 19 | + r = random.random([40, int(512 / 2) + 1]).astype(float_type) | |
| 20 | 20 | f.set_coeffs(r) |
| 21 | 21 | assert_equal (r, f.get_coeffs()) |
| 22 | 22 | |
| @@ -35,16 +35,16 @@ class aubio_filterbank_test_case(TestCase): · 12 unmodified lines | ||
| 35 | 35 | def test_random_norm(self): |
| 36 | 36 | f = filterbank(40, 512) |
| 37 | 37 | c = cvec(512) |
| 38 | − c.norm[:] = random.random((int(512 / 2) + 1,)).astype('float32') | |
| 38 | + c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 39 | 39 | assert_equal( f(c), 0) |
| 40 | 40 | |
| 41 | 41 | def test_random_coeffs(self): |
| 42 | 42 | f = filterbank(40, 512) |
| 43 | 43 | c = cvec(512) |
| 44 | − r = random.random([40, int(512 / 2) + 1]).astype('float32') | |
| 44 | + r = random.random([40, int(512 / 2) + 1]).astype(float_type) | |
| 45 | 45 | r /= r.sum() |
| 46 | 46 | f.set_coeffs(r) |
| 47 | − c.norm[:] = random.random((int(512 / 2) + 1,)).astype('float32') | |
| 47 | + c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 48 | 48 | assert_equal ( f(c) < 1., True ) |
| 49 | 49 | assert_equal ( f(c) > 0., True ) |
| 50 | 50 | |
| @@ -52,7 +52,7 @@ class aubio_filterbank_test_case(TestCase): · 1 unmodified line | ||
| 52 | 52 | f = filterbank(40, 512) |
| 53 | 53 | c = cvec(512) |
| 54 | 54 | f.set_mel_coeffs_slaney(44100) |
| 55 | − c.norm[:] = random.random((int(512 / 2) + 1,)).astype('float32') | |
| 55 | + c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 56 | 56 | assert_equal ( f(c) < 1., True ) |
| 57 | 57 | assert_equal ( f(c) > 0., True ) |
| 58 | 58 | |
| @@ -3,7 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | from numpy.testing import TestCase, run_module_suite |
| 4 | 4 | from numpy.testing import assert_equal, assert_almost_equal |
| 5 | 5 | from numpy import array, shape |
| 6 | −from aubio import cvec, filterbank | |
| 6 | +from aubio import cvec, filterbank, float_type | |
| 7 | 7 | |
| 8 | 8 | class aubio_filterbank_mel_test_case(TestCase): |
| 9 | 9 | |
| @@ -27,7 +27,7 @@ class aubio_filterbank_mel_test_case(TestCase): · 17 unmodified lines | ||
| 27 | 27 | def test_triangle_freqs_zeros(self): |
| 28 | 28 | f = filterbank(9, 1024) |
| 29 | 29 | freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] |
| 30 | − freqs = array(freq_list, dtype = 'float32') | |
| 30 | + freqs = array(freq_list, dtype = float_type) | |
| 31 | 31 | f.set_triangle_bands(freqs, 48000) |
| 32 | 32 | f.get_coeffs().T |
| 33 | 33 | assert_equal ( f(cvec(1024)), 0) |
| @@ -35,7 +35,7 @@ class aubio_filterbank_mel_test_case(TestCase): · 1 unmodified line | ||
| 35 | 35 | def test_triangle_freqs_ones(self): |
| 36 | 36 | f = filterbank(9, 1024) |
| 37 | 37 | freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] |
| 38 | − freqs = array(freq_list, dtype = 'float32') | |
| 38 | + freqs = array(freq_list, dtype = float_type) | |
| 39 | 39 | f.set_triangle_bands(freqs, 48000) |
| 40 | 40 | f.get_coeffs().T |
| 41 | 41 | spec = cvec(1024) |
| @@ -3,21 +3,24 @@ · 2 unmodified lines | ||
| 3 | 3 | from numpy.testing import TestCase, run_module_suite |
| 4 | 4 | from numpy.testing import assert_equal, assert_almost_equal |
| 5 | 5 | from aubio import fvec, zero_crossing_rate, alpha_norm, min_removal |
| 6 | +from aubio import float_type | |
| 6 | 7 | from numpy import array, shape |
| 7 | 8 | |
| 9 | +wrong_type = 'float32' if float_type == 'float64' else 'float64' | |
| 10 | + | |
| 8 | 11 | default_size = 512 |
| 9 | 12 | |
| 10 | 13 | class aubio_fvec_test_case(TestCase): |
| 11 | 14 | |
| 12 | 15 | def test_vector_created_with_zeroes(self): |
| 13 | 16 | a = fvec(10) |
| 14 | − assert a.dtype == 'float32' | |
| 17 | + assert a.dtype == float_type | |
| 15 | 18 | assert a.shape == (10,) |
| 16 | 19 | assert_equal (a, 0) |
| 17 | 20 | |
| 18 | 21 | def test_vector_create_with_list(self): |
| 19 | 22 | a = fvec([0,1,2,3]) |
| 20 | − assert a.dtype == 'float32' | |
| 23 | + assert a.dtype == float_type | |
| 21 | 24 | assert a.shape == (4,) |
| 22 | 25 | assert_equal (list(range(4)), a) |
| 23 | 26 | |
| @@ -57,7 +60,7 @@ class aubio_fvec_test_case(TestCase): · 33 unmodified lines | ||
| 57 | 60 | self.assertEqual (alpha_norm(a, 1), 0.5) |
| 58 | 61 | a[1] = 1 |
| 59 | 62 | self.assertEqual (alpha_norm(a, 1), 1) |
| 60 | − a = array([0, 1], dtype='float32') | |
| 63 | + a = array([0, 1], dtype=float_type) | |
| 61 | 64 | from math import sqrt |
| 62 | 65 | assert_almost_equal (alpha_norm(a, 2), sqrt(2)/2.) |
| 63 | 66 | |
| @@ -66,13 +69,13 @@ class aubio_fvec_test_case(TestCase): · 2 unmodified lines | ||
| 66 | 69 | |
| 67 | 70 | def test_alpha_norm_of_array_of_float32(self): |
| 68 | 71 | # check scalar fails |
| 69 | − a = array(1, dtype = 'float32') | |
| 72 | + a = array(1, dtype = float_type) | |
| 70 | 73 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 71 | 74 | # check 2d array fails |
| 72 | − a = array([[2],[4]], dtype = 'float32') | |
| 75 | + a = array([[2],[4]], dtype = float_type) | |
| 73 | 76 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 74 | 77 | # check 1d array |
| 75 | − a = array(range(10), dtype = 'float32') | |
| 78 | + a = array(range(10), dtype = float_type) | |
| 76 | 79 | self.assertEqual (alpha_norm(a, 1), 4.5) |
| 77 | 80 | |
| 78 | 81 | def test_alpha_norm_of_array_of_int(self): |
| @@ -88,31 +91,31 @@ class aubio_fvec_test_case(TestCase): · 9 unmodified lines | ||
| 88 | 91 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 89 | 92 | |
| 90 | 93 | def test_zero_crossing_rate(self): |
| 91 | − a = array([0,1,-1], dtype='float32') | |
| 94 | + a = array([0,1,-1], dtype=float_type) | |
| 92 | 95 | assert_almost_equal (zero_crossing_rate(a), 1./3. ) |
| 93 | − a = array([0.]*100, dtype='float32') | |
| 96 | + a = array([0.]*100, dtype=float_type) | |
| 94 | 97 | self.assertEqual (zero_crossing_rate(a), 0 ) |
| 95 | − a = array([-1.]*100, dtype='float32') | |
| 98 | + a = array([-1.]*100, dtype=float_type) | |
| 96 | 99 | self.assertEqual (zero_crossing_rate(a), 0 ) |
| 97 | − a = array([1.]*100, dtype='float32') | |
| 100 | + a = array([1.]*100, dtype=float_type) | |
| 98 | 101 | self.assertEqual (zero_crossing_rate(a), 0 ) |
| 99 | 102 | |
| 100 | 103 | def test_alpha_norm_of_array_of_float64(self): |
| 101 | 104 | # check scalar fail |
| 102 | − a = array(1, dtype = 'float64') | |
| 105 | + a = array(1, dtype = wrong_type) | |
| 103 | 106 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 104 | 107 | # check 3d array fail |
| 105 | − a = array([[[1,2],[3,4]]], dtype = 'float64') | |
| 108 | + a = array([[[1,2],[3,4]]], dtype = wrong_type) | |
| 106 | 109 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 107 | 110 | # check float64 1d array fail |
| 108 | − a = array(list(range(10)), dtype = 'float64') | |
| 111 | + a = array(list(range(10)), dtype = wrong_type) | |
| 109 | 112 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 110 | 113 | # check float64 2d array fail |
| 111 | − a = array([list(range(10)), list(range(10))], dtype = 'float64') | |
| 114 | + a = array([list(range(10)), list(range(10))], dtype = wrong_type) | |
| 112 | 115 | self.assertRaises (ValueError, alpha_norm, a, 1) |
| 113 | 116 | |
| 114 | 117 | def test_fvec_min_removal_of_array(self): |
| 115 | − a = array([20,1,19], dtype='float32') | |
| 118 | + a = array([20,1,19], dtype=float_type) | |
| 116 | 119 | b = min_removal(a) |
| 117 | 120 | assert_equal (array(b), [19, 0, 18]) |
| 118 | 121 | assert_equal (b, [19, 0, 18]) |
| @@ -121,12 +124,12 @@ class aubio_fvec_test_case(TestCase): · 2 unmodified lines | ||
| 121 | 124 | assert_equal (a, b) |
| 122 | 125 | |
| 123 | 126 | def test_fvec_min_removal_of_array_float64(self): |
| 124 | − a = array([20,1,19], dtype='float64') | |
| 127 | + a = array([20,1,19], dtype=wrong_type) | |
| 125 | 128 | self.assertRaises (ValueError, min_removal, a) |
| 126 | 129 | |
| 127 | 130 | def test_fvec_min_removal_of_fvec(self): |
| 128 | 131 | a = fvec(3) |
| 129 | − a = array([20, 1, 19], dtype = 'float32') | |
| 132 | + a = array([20, 1, 19], dtype = float_type) | |
| 130 | 133 | b = min_removal(a) |
| 131 | 134 | assert_equal (array(b), [19, 0, 18]) |
| 132 | 135 | assert_equal (b, [19, 0, 18]) |
| @@ -7,7 +7,7 @@ from math import pi · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | from aubio import window, level_lin, db_spl, silence_detection, level_detection |
| 9 | 9 | |
| 10 | −from aubio import fvec | |
| 10 | +from aubio import fvec, float_type | |
| 11 | 11 | |
| 12 | 12 | class aubio_window(TestCase): |
| 13 | 13 | |
| @@ -53,7 +53,7 @@ class aubio_level_lin(TestCase): · 39 unmodified lines | ||
| 53 | 53 | |
| 54 | 54 | def test_minus_ones_is_one(self): |
| 55 | 55 | from numpy import ones |
| 56 | − assert_equal(level_lin(-ones(1024, dtype="float32")), 1.) | |
| 56 | + assert_equal(level_lin(-ones(1024, dtype = float_type)), 1.) | |
| 57 | 57 | |
| 58 | 58 | class aubio_db_spl(TestCase): |
| 59 | 59 | def test_accept_fvec(self): |
| @@ -73,7 +73,7 @@ class aubio_db_spl(TestCase): · 13 unmodified lines | ||
| 73 | 73 | |
| 74 | 74 | def test_minus_ones_is_zero(self): |
| 75 | 75 | from numpy import ones |
| 76 | − assert_equal(db_spl(-ones(1024, dtype="float32")), 0.) | |
| 76 | + assert_equal(db_spl(-ones(1024, dtype = float_type)), 0.) | |
| 77 | 77 | |
| 78 | 78 | class aubio_silence_detection(TestCase): |
| 79 | 79 | def test_accept_fvec(self): |
| @@ -93,7 +93,7 @@ class aubio_silence_detection(TestCase): · 13 unmodified lines | ||
| 93 | 93 | |
| 94 | 94 | def test_minus_ones_is_zero(self): |
| 95 | 95 | from numpy import ones |
| 96 | − assert silence_detection(ones(1024, dtype="float32"), -70) == 0 | |
| 96 | + assert silence_detection(ones(1024, dtype = float_type), -70) == 0 | |
| 97 | 97 | |
| 98 | 98 | class aubio_level_detection(TestCase): |
| 99 | 99 | def test_accept_fvec(self): |
| @@ -113,7 +113,7 @@ class aubio_level_detection(TestCase): · 13 unmodified lines | ||
| 113 | 113 | |
| 114 | 114 | def test_minus_ones_is_zero(self): |
| 115 | 115 | from numpy import ones |
| 116 | − assert level_detection(ones(1024, dtype="float32"), -70) == 0 | |
| 116 | + assert level_detection(ones(1024, dtype = float_type), -70) == 0 | |
| 117 | 117 | |
| 118 | 118 | if __name__ == '__main__': |
| 119 | 119 | from unittest import main |
| @@ -4,7 +4,7 @@ from unittest import TestCase · 3 unmodified lines | ||
| 4 | 4 | from numpy.testing import assert_equal, assert_almost_equal |
| 5 | 5 | from numpy import random, sin, arange, mean, median, isnan |
| 6 | 6 | from math import pi |
| 7 | −from aubio import fvec, pitch, freqtomidi | |
| 7 | +from aubio import fvec, pitch, freqtomidi, float_type | |
| 8 | 8 | |
| 9 | 9 | class aubio_pitch_Good_Values(TestCase): |
| 10 | 10 | |
| @@ -50,7 +50,7 @@ class aubio_pitch_Sinusoid(TestCase): · 39 unmodified lines | ||
| 50 | 50 | self.run_pitch(p, sinvec, freq) |
| 51 | 51 | |
| 52 | 52 | def build_sinusoid(self, length, freq, samplerate): |
| 53 | − return sin( 2. * pi * arange(length).astype('float32') * freq / samplerate) | |
| 53 | + return sin( 2. * pi * arange(length).astype(float_type) * freq / samplerate) | |
| 54 | 54 | |
| 55 | 55 | def run_pitch(self, p, input_vec, freq): |
| 56 | 56 | count = 0 |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | from numpy.testing import TestCase, assert_equal, assert_almost_equal |
| 4 | 4 | from numpy import random, arange, log, zeros |
| 5 | −from aubio import specdesc, cvec | |
| 5 | +from aubio import specdesc, cvec, float_type | |
| 6 | 6 | from math import pi |
| 7 | 7 | |
| 8 | 8 | methods = ["default", |
| @@ -37,8 +37,8 @@ class aubio_specdesc(TestCase): · 28 unmodified lines | ||
| 37 | 37 | spec.norm[1] = 1./2. |
| 38 | 38 | #print "%20s" % method, str(o(spec)) |
| 39 | 39 | o(spec) |
| 40 | − spec.norm = random.random_sample((len(spec.norm),)).astype('float32') | |
| 41 | − spec.phas = random.random_sample((len(spec.phas),)).astype('float32') | |
| 40 | + spec.norm = random.random_sample((len(spec.norm),)).astype(float_type) | |
| 41 | + spec.phas = random.random_sample((len(spec.phas),)).astype(float_type) | |
| 42 | 42 | #print "%20s" % method, str(o(spec)) |
| 43 | 43 | assert (o(spec) != 0.) |
| 44 | 44 | |
| @@ -60,7 +60,7 @@ class aubio_specdesc(TestCase): · 15 unmodified lines | ||
| 60 | 60 | spec = cvec(buf_size) |
| 61 | 61 | # phase of zeros is zero |
| 62 | 62 | assert_equal (o(spec), 0.) |
| 63 | − spec.phas = random.random_sample((len(spec.phas),)).astype('float32') | |
| 63 | + spec.phas = random.random_sample((len(spec.phas),)).astype(float_type) | |
| 64 | 64 | # phase of random is not zero |
| 65 | 65 | spec.norm[:] = 1 |
| 66 | 66 | assert (o(spec) != 0.) |
| @@ -70,7 +70,7 @@ class aubio_specdesc(TestCase): · 3 unmodified lines | ||
| 70 | 70 | spec = cvec(buf_size) |
| 71 | 71 | # specdiff of zeros is zero |
| 72 | 72 | assert_equal (o(spec), 0.) |
| 73 | − spec.phas = random.random_sample((len(spec.phas),)).astype('float32') | |
| 73 | + spec.phas = random.random_sample((len(spec.phas),)).astype(float_type) | |
| 74 | 74 | # phase of random is not zero |
| 75 | 75 | spec.norm[:] = 1 |
| 76 | 76 | assert (o(spec) != 0.) |
| @@ -79,7 +79,7 @@ class aubio_specdesc(TestCase): · 2 unmodified lines | ||
| 79 | 79 | o = specdesc("hfc") |
| 80 | 80 | c = cvec() |
| 81 | 81 | assert_equal( 0., o(c)) |
| 82 | − a = arange(c.length, dtype='float32') | |
| 82 | + a = arange(c.length, dtype=float_type) | |
| 83 | 83 | c.norm = a |
| 84 | 84 | assert_equal (a, c.norm) |
| 85 | 85 | assert_equal ( sum(a*(a+1)), o(c)) |
| @@ -88,7 +88,7 @@ class aubio_specdesc(TestCase): · 2 unmodified lines | ||
| 88 | 88 | o = specdesc("complex") |
| 89 | 89 | c = cvec() |
| 90 | 90 | assert_equal( 0., o(c)) |
| 91 | − a = arange(c.length, dtype='float32') | |
| 91 | + a = arange(c.length, dtype=float_type) | |
| 92 | 92 | c.norm = a |
| 93 | 93 | assert_equal (a, c.norm) |
| 94 | 94 | # the previous run was on zeros, so previous frames are still 0 |
| @@ -101,7 +101,7 @@ class aubio_specdesc(TestCase): · 6 unmodified lines | ||
| 101 | 101 | o = specdesc("kl") |
| 102 | 102 | c = cvec() |
| 103 | 103 | assert_equal( 0., o(c)) |
| 104 | − a = arange(c.length, dtype='float32') | |
| 104 | + a = arange(c.length, dtype=float_type) | |
| 105 | 105 | c.norm = a |
| 106 | 106 | assert_almost_equal( sum(a * log(1.+ a/1.e-1 ) ) / o(c), 1., decimal=6) |
| 107 | 107 | |
| @@ -109,7 +109,7 @@ class aubio_specdesc(TestCase): · 1 unmodified line | ||
| 109 | 109 | o = specdesc("mkl") |
| 110 | 110 | c = cvec() |
| 111 | 111 | assert_equal( 0., o(c)) |
| 112 | − a = arange(c.length, dtype='float32') | |
| 112 | + a = arange(c.length, dtype=float_type) | |
| 113 | 113 | c.norm = a |
| 114 | 114 | assert_almost_equal( sum(log(1.+ a/1.e-1 ) ) / o(c), 1, decimal=6) |
| 115 | 115 | |
| @@ -117,11 +117,11 @@ class aubio_specdesc(TestCase): · 1 unmodified line | ||
| 117 | 117 | o = specdesc("specflux") |
| 118 | 118 | c = cvec() |
| 119 | 119 | assert_equal( 0., o(c)) |
| 120 | − a = arange(c.length, dtype='float32') | |
| 120 | + a = arange(c.length, dtype=float_type) | |
| 121 | 121 | c.norm = a |
| 122 | 122 | assert_equal( sum(a), o(c)) |
| 123 | 123 | assert_equal( 0, o(c)) |
| 124 | − c.norm = zeros(c.length, dtype='float32') | |
| 124 | + c.norm = zeros(c.length, dtype=float_type) | |
| 125 | 125 | assert_equal( 0, o(c)) |
| 126 | 126 | |
| 127 | 127 | def test_centroid(self): |
| @@ -129,7 +129,7 @@ class aubio_specdesc(TestCase): · 1 unmodified line | ||
| 129 | 129 | c = cvec() |
| 130 | 130 | # make sure centroid of zeros is zero |
| 131 | 131 | assert_equal( 0., o(c)) |
| 132 | − a = arange(c.length, dtype='float32') | |
| 132 | + a = arange(c.length, dtype=float_type) | |
| 133 | 133 | c.norm = a |
| 134 | 134 | centroid = sum(a*a) / sum(a) |
| 135 | 135 | assert_almost_equal (centroid, o(c), decimal = 2) |
| @@ -140,7 +140,7 @@ class aubio_specdesc(TestCase): · 4 unmodified lines | ||
| 140 | 140 | def test_spread(self): |
| 141 | 141 | o = specdesc("spread") |
| 142 | 142 | c = cvec(2048) |
| 143 | − ramp = arange(c.length, dtype='float32') | |
| 143 | + ramp = arange(c.length, dtype=float_type) | |
| 144 | 144 | assert_equal( 0., o(c)) |
| 145 | 145 | |
| 146 | 146 | a = ramp |
| @@ -153,7 +153,7 @@ class aubio_specdesc(TestCase): · 6 unmodified lines | ||
| 153 | 153 | o = specdesc("skewness") |
| 154 | 154 | c = cvec() |
| 155 | 155 | assert_equal( 0., o(c)) |
| 156 | − a = arange(c.length, dtype='float32') | |
| 156 | + a = arange(c.length, dtype=float_type) | |
| 157 | 157 | c.norm = a |
| 158 | 158 | centroid = sum(a*a) / sum(a) |
| 159 | 159 | spread = sum( (a - centroid)**2 *a) / sum(a) |
| @@ -167,7 +167,7 @@ class aubio_specdesc(TestCase): · 7 unmodified lines | ||
| 167 | 167 | o = specdesc("kurtosis") |
| 168 | 168 | c = cvec() |
| 169 | 169 | assert_equal( 0., o(c)) |
| 170 | − a = arange(c.length, dtype='float32') | |
| 170 | + a = arange(c.length, dtype=float_type) | |
| 171 | 171 | c.norm = a |
| 172 | 172 | centroid = sum(a*a) / sum(a) |
| 173 | 173 | spread = sum( (a - centroid)**2 *a) / sum(a) |
| @@ -178,22 +178,22 @@ class aubio_specdesc(TestCase): · 4 unmodified lines | ||
| 178 | 178 | o = specdesc("slope") |
| 179 | 179 | c = cvec() |
| 180 | 180 | assert_equal( 0., o(c)) |
| 181 | − a = arange(c.length * 2, 0, -2, dtype='float32') | |
| 182 | − k = arange(c.length, dtype='float32') | |
| 181 | + a = arange(c.length * 2, 0, -2, dtype=float_type) | |
| 182 | + k = arange(c.length, dtype=float_type) | |
| 183 | 183 | c.norm = a |
| 184 | 184 | num = len(a) * sum(k*a) - sum(k)*sum(a) |
| 185 | 185 | den = (len(a) * sum(k**2) - sum(k)**2) |
| 186 | 186 | slope = num/den/sum(a) |
| 187 | 187 | assert_almost_equal (slope, o(c), decimal = 5) |
| 188 | 188 | |
| 189 | − a = arange(0, c.length * 2, +2, dtype='float32') | |
| 189 | + a = arange(0, c.length * 2, +2, dtype=float_type) | |
| 190 | 190 | c.norm = a |
| 191 | 191 | num = len(a) * sum(k*a) - sum(k)*sum(a) |
| 192 | 192 | den = (len(a) * sum(k**2) - sum(k)**2) |
| 193 | 193 | slope = num/den/sum(a) |
| 194 | 194 | assert_almost_equal (slope, o(c), decimal = 5) |
| 195 | 195 | |
| 196 | − a = arange(0, c.length * 2, +2, dtype='float32') | |
| 196 | + a = arange(0, c.length * 2, +2, dtype=float_type) | |
| 197 | 197 | c.norm = a * 2 |
| 198 | 198 | assert_almost_equal (slope, o(c), decimal = 5) |
| 199 | 199 | |
| @@ -201,18 +201,18 @@ class aubio_specdesc(TestCase): · 1 unmodified line | ||
| 201 | 201 | o = specdesc("decrease") |
| 202 | 202 | c = cvec() |
| 203 | 203 | assert_equal( 0., o(c)) |
| 204 | − a = arange(c.length * 2, 0, -2, dtype='float32') | |
| 205 | − k = arange(c.length, dtype='float32') | |
| 204 | + a = arange(c.length * 2, 0, -2, dtype=float_type) | |
| 205 | + k = arange(c.length, dtype=float_type) | |
| 206 | 206 | c.norm = a |
| 207 | 207 | decrease = sum((a[1:] - a [0]) / k[1:]) / sum(a[1:]) |
| 208 | 208 | assert_almost_equal (decrease, o(c), decimal = 5) |
| 209 | 209 | |
| 210 | − a = arange(0, c.length * 2, +2, dtype='float32') | |
| 210 | + a = arange(0, c.length * 2, +2, dtype=float_type) | |
| 211 | 211 | c.norm = a |
| 212 | 212 | decrease = sum((a[1:] - a [0]) / k[1:]) / sum(a[1:]) |
| 213 | 213 | assert_almost_equal (decrease, o(c), decimal = 5) |
| 214 | 214 | |
| 215 | − a = arange(0, c.length * 2, +2, dtype='float32') | |
| 215 | + a = arange(0, c.length * 2, +2, dtype=float_type) | |
| 216 | 216 | c.norm = a * 2 |
| 217 | 217 | decrease = sum((a[1:] - a [0]) / k[1:]) / sum(a[1:]) |
| 218 | 218 | assert_almost_equal (decrease, o(c), decimal = 5) |
| @@ -221,8 +221,8 @@ class aubio_specdesc(TestCase): · 2 unmodified lines | ||
| 221 | 221 | o = specdesc("rolloff") |
| 222 | 222 | c = cvec() |
| 223 | 223 | assert_equal( 0., o(c)) |
| 224 | − a = arange(c.length * 2, 0, -2, dtype='float32') | |
| 225 | − k = arange(c.length, dtype='float32') | |
| 224 | + a = arange(c.length * 2, 0, -2, dtype=float_type) | |
| 225 | + k = arange(c.length, dtype=float_type) | |
| 226 | 226 | c.norm = a |
| 227 | 227 | cumsum = .95*sum(a*a) |
| 228 | 228 | i = 0; rollsum = 0 |