Showing the changes to python (2 of 2 files). Show all
Unified · Split
| @@ -92,6 +92,13 @@ Py_filterbank_do(Py_filterbank * self, PyObject * args) · 91 unmodified lines | ||
| 92 | 92 | return NULL; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | + if (self->vec.length != self->win_s / 2 + 1) { | |
| 96 | + PyErr_Format(PyExc_ValueError, | |
| 97 | + "input cvec has length %d, but fft expects length %d", | |
| 98 | + self->vec.length, self->win_s / 2 + 1); | |
| 99 | + return NULL; | |
| 100 | + } | |
| 101 | + | |
| 95 | 102 | Py_INCREF(self->out); |
| 96 | 103 | if (!PyAubio_ArrayToCFvec(self->out, &(self->c_out))) { |
| 97 | 104 | return NULL; |
| @@ -61,6 +61,16 @@ class aubio_filterbank_test_case(TestCase): · 60 unmodified lines | ||
| 61 | 61 | f.set_mel_coeffs_slaney(16000) |
| 62 | 62 | assert_almost_equal ( expected, f.get_coeffs() ) |
| 63 | 63 | |
| 64 | + def test_filterbank_long_cvec(self): | |
| 65 | + f = filterbank(40, 512) | |
| 66 | + with self.assertRaises(ValueError): | |
| 67 | + f(cvec(1024)) | |
| 68 | + | |
| 69 | + def test_filterbank_short_cvec(self): | |
| 70 | + f = filterbank(40, 512) | |
| 71 | + with self.assertRaises(ValueError): | |
| 72 | + f(cvec(256)) | |
| 73 | + | |
| 64 | 74 | if __name__ == '__main__': |
| 65 | 75 | from nose2 import main |
| 66 | 76 | main() |