Showing the changes to python (1 of 2 files). Show all
Unified · Split
| @@ -142,6 +142,37 @@ class aubio_fft_test_case(TestCase): · 141 unmodified lines | |||
| 142 | assert_almost_equal ( r[0], impulse, decimal = 6) | 142 | assert_almost_equal ( r[0], impulse, decimal = 6) |
| 143 | assert_almost_equal ( r[1:], 0) | 143 | assert_almost_equal ( r[1:], 0) |
| 144 | 144 | ||
| 145 | class aubio_fft_odd_sizes(TestCase): | ||
| 146 | |||
| 147 | def test_reconstruct_with_odd_size(self): | ||
| 148 | win_s = 29 | ||
| 149 | self.recontruct(win_s, 'odd sizes not supported') | ||
| 150 | |||
| 151 | def test_reconstruct_with_radix15(self): | ||
| 152 | win_s = 2 ** 4 * 15 | ||
| 153 | self.recontruct(win_s, 'radix 15 supported') | ||
| 154 | |||
| 155 | def test_reconstruct_with_radix5(self): | ||
| 156 | win_s = 2 ** 4 * 5 | ||
| 157 | self.recontruct(win_s, 'radix 5 supported') | ||
| 158 | |||
| 159 | def test_reconstruct_with_radix3(self): | ||
| 160 | win_s = 2 ** 4 * 3 | ||
| 161 | self.recontruct(win_s, 'radix 3 supported') | ||
| 162 | |||
| 163 | def recontruct(self, win_s, skipMessage): | ||
| 164 | try: | ||
| 165 | f = fft(win_s) | ||
| 166 | except RuntimeError: | ||
| 167 | self.skipTest(skipMessage) | ||
| 168 | input_signal = fvec(win_s) | ||
| 169 | input_signal[win_s//2] = 1 | ||
| 170 | c = f(input_signal) | ||
| 171 | output_signal = f.rdo(c) | ||
| 172 | assert_almost_equal(input_signal, output_signal) | ||
| 173 | |||
| 174 | class aubio_fft_wrong_params(TestCase): | ||
| 175 | |||
| 145 | def test_large_input_timegrain(self): | 176 | def test_large_input_timegrain(self): |
| 146 | win_s = 1024 | 177 | win_s = 1024 |
| 147 | f = fft(win_s) | 178 | f = fft(win_s) |
| @@ -170,22 +201,11 @@ class aubio_fft_test_case(TestCase): · 22 unmodified lines | |||
| 170 | with self.assertRaises(ValueError): | 201 | with self.assertRaises(ValueError): |
| 171 | f.rdo(s) | 202 | f.rdo(s) |
| 172 | 203 | ||
| 173 | class aubio_fft_wrong_params(TestCase): | ||
| 174 | |||
| 175 | def test_wrong_buf_size(self): | 204 | def test_wrong_buf_size(self): |
| 176 | win_s = -1 | 205 | win_s = -1 |
| 177 | with self.assertRaises(ValueError): | 206 | with self.assertRaises(ValueError): |
| 178 | fft(win_s) | 207 | fft(win_s) |
| 179 | 208 | ||
| 180 | def test_buf_size_not_power_of_two(self): | ||
| 181 | # when compiled with fftw3, aubio supports non power of two fft sizes | ||
| 182 | win_s = 320 | ||
| 183 | try: | ||
| 184 | with self.assertRaises(RuntimeError): | ||
| 185 | fft(win_s) | ||
| 186 | except AssertionError: | ||
| 187 | self.skipTest('creating aubio.fft with size %d did not fail' % win_s) | ||
| 188 | |||
| 189 | def test_buf_size_too_small(self): | 209 | def test_buf_size_too_small(self): |
| 190 | win_s = 1 | 210 | win_s = 1 |
| 191 | with self.assertRaises(RuntimeError): | 211 | with self.assertRaises(RuntimeError): |