Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -21,6 +21,7 @@ PyAubio_CFvecToArray (fvec_t * self) · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | int | 22 | int |
| 23 | PyAubio_IsValidVector (PyObject * input) { | 23 | PyAubio_IsValidVector (PyObject * input) { |
| 24 | npy_intp length; | ||
| 24 | if (input == NULL) { | 25 | if (input == NULL) { |
| 25 | PyErr_SetString (PyExc_ValueError, "input array is not a python object"); | 26 | PyErr_SetString (PyExc_ValueError, "input array is not a python object"); |
| 26 | return 0; | 27 | return 0; |
| @@ -46,7 +47,7 @@ PyAubio_IsValidVector (PyObject * input) { · 19 unmodified lines | |||
| 46 | return 0; | 47 | return 0; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | npy_intp length = PyArray_SIZE ((PyArrayObject *)input); | 50 | length = PyArray_SIZE ((PyArrayObject *)input); |
| 50 | if (length <= 0) { | 51 | if (length <= 0) { |
| 51 | PyErr_SetString (PyExc_ValueError, "input array size should be greater than 0"); | 52 | PyErr_SetString (PyExc_ValueError, "input array size should be greater than 0"); |
| 52 | return 0; | 53 | return 0; |
| @@ -93,7 +94,8 @@ PyAubio_CFmatToArray (fmat_t * input) · 40 unmodified lines | |||
| 93 | 94 | ||
| 94 | int | 95 | int |
| 95 | PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) { | 96 | PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) { |
| 96 | uint_t i; | 97 | uint_t i, new_height; |
| 98 | npy_intp length, height; | ||
| 97 | if (input == NULL) { | 99 | if (input == NULL) { |
| 98 | PyErr_SetString (PyExc_ValueError, "input array is not a python object"); | 100 | PyErr_SetString (PyExc_ValueError, "input array is not a python object"); |
| 99 | return 0; | 101 | return 0; |
| @@ -120,12 +122,12 @@ PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) { · 20 unmodified lines | |||
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | // no need to really allocate fvec, just its struct member | 124 | // no need to really allocate fvec, just its struct member |
| 123 | npy_intp length = PyArray_DIM ((PyArrayObject *)input, 1); | 125 | length = PyArray_DIM ((PyArrayObject *)input, 1); |
| 124 | if (length <= 0) { | 126 | if (length <= 0) { |
| 125 | PyErr_SetString (PyExc_ValueError, "input array dimension 1 should be greater than 0"); | 127 | PyErr_SetString (PyExc_ValueError, "input array dimension 1 should be greater than 0"); |
| 126 | return 0; | 128 | return 0; |
| 127 | } | 129 | } |
| 128 | npy_intp height = PyArray_DIM ((PyArrayObject *)input, 0); | 130 | height = PyArray_DIM ((PyArrayObject *)input, 0); |
| 129 | if (height <= 0) { | 131 | if (height <= 0) { |
| 130 | PyErr_SetString (PyExc_ValueError, "input array dimension 0 should be greater than 0"); | 132 | PyErr_SetString (PyExc_ValueError, "input array dimension 0 should be greater than 0"); |
| 131 | return 0; | 133 | return 0; |
| @@ -139,7 +141,7 @@ PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) { · 7 unmodified lines | |||
| 139 | return 0; | 141 | return 0; |
| 140 | } | 142 | } |
| 141 | 143 | ||
| 142 | uint_t new_height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0); | 144 | new_height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0); |
| 143 | if (mat->height != new_height) { | 145 | if (mat->height != new_height) { |
| 144 | if (mat->data) { | 146 | if (mat->data) { |
| 145 | free(mat->data); | 147 | free(mat->data); |