Index: python/ext/aubio-types.h
===================================================================
--- python/ext/aubio-types.h	(revision ece990f15b62b331460b649b9e96d3d0b96a14b9)
+++ python/ext/aubio-types.h	(revision 34d0c257cd6adea857415c783d9a3f1d9bf42ac3)
@@ -59,4 +59,6 @@
 
 // defined in aubio-proxy.c
+extern int PyAubio_IsValidVector (PyObject *input);
+
 extern PyObject *PyAubio_CFvecToArray (fvec_t * self);
 extern int PyAubio_ArrayToCFvec (PyObject * self, fvec_t *out);
Index: python/ext/aubioproxy.c
===================================================================
--- python/ext/aubioproxy.c	(revision ece990f15b62b331460b649b9e96d3d0b96a14b9)
+++ python/ext/aubioproxy.c	(revision 34d0c257cd6adea857415c783d9a3f1d9bf42ac3)
@@ -21,5 +21,5 @@
 
 int
-PyAubio_ArrayToCFvec (PyObject *input, fvec_t *out) {
+PyAubio_IsValidVector (PyObject * input) {
   if (input == NULL) {
     PyErr_SetString (PyExc_ValueError, "input array is not a python object");
@@ -47,6 +47,4 @@
     }
 
-    // vec = new_fvec (vec->length);
-    // no need to really allocate fvec, just its struct member
     long length = PyArray_SIZE ((PyArrayObject *)input);
     if (length <= 0) {
@@ -60,4 +58,13 @@
   } else {
     PyErr_SetString (PyExc_ValueError, "can only accept vector of float as input");
+    return 0;
+  }
+  return 1;
+}
+
+int
+PyAubio_ArrayToCFvec (PyObject *input, fvec_t *out) {
+
+  if (!PyAubio_IsValidVector(input)){
     return 0;
   }
Index: python/ext/py-cvec.c
===================================================================
--- python/ext/py-cvec.c	(revision ece990f15b62b331460b649b9e96d3d0b96a14b9)
+++ python/ext/py-cvec.c	(revision 34d0c257cd6adea857415c783d9a3f1d9bf42ac3)
@@ -155,57 +155,19 @@
 Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
 {
-  PyArrayObject * array;
-  if (input == NULL) {
-    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
-    goto fail;
-  }
-  if (PyArray_Check(input)) {
-    // we got an array, convert it to a cvec.norm
-    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
-      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
-      goto fail;
-    } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
-      PyErr_SetString (PyExc_ValueError,
-          "input array has more than two dimensions");
-      goto fail;
-    }
-
-    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
-      PyErr_SetString (PyExc_ValueError, "input array should be float");
-      goto fail;
-    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
-      PyErr_SetString (PyExc_ValueError, "input array should be float32");
-      goto fail;
-    }
-    array = (PyArrayObject *)input;
-
-    // check input array dimensions
-    if (PyArray_NDIM (array) != 1) {
-      PyErr_Format (PyExc_ValueError,
-          "input array has %d dimensions, not 1",
-          PyArray_NDIM (array));
-      goto fail;
-    } else {
-      if (vec->length != PyArray_SIZE (array)) {
-          PyErr_Format (PyExc_ValueError,
-                  "input array has length %d, but cvec has length %d",
-                  (int)PyArray_SIZE (array), vec->length);
-          goto fail;
-      }
-    }
-
-    Py_XDECREF(vec->norm);
-    vec->norm = input;
-    Py_INCREF(vec->norm);
-
-  } else {
-    PyErr_SetString (PyExc_ValueError, "can only accept array as input");
-    return 1;
-  }
-
+  if (!PyAubio_IsValidVector(input)) {
+    return 1;
+  }
+  long length = PyArray_SIZE ((PyArrayObject *)input);
+  if (length != vec->length) {
+    PyErr_Format (PyExc_ValueError,
+        "input array has length %ld, but cvec has length %d", length,
+        vec->length);
+    return 1;
+  }
+
+  Py_XDECREF(vec->norm);
+  vec->norm = input;
+  Py_INCREF(vec->norm);
   return 0;
-
-fail:
-  return 1;
 }
 
@@ -213,58 +175,19 @@
 Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
 {
-  PyArrayObject * array;
-  if (input == NULL) {
-    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
-    goto fail;
-  }
-  if (PyArray_Check(input)) {
-
-    // we got an array, convert it to a cvec.phas
-    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
-      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
-      goto fail;
-    } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
-      PyErr_SetString (PyExc_ValueError,
-          "input array has more than two dimensions");
-      goto fail;
-    }
-
-    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
-      PyErr_SetString (PyExc_ValueError, "input array should be float");
-      goto fail;
-    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
-      PyErr_SetString (PyExc_ValueError, "input array should be float32");
-      goto fail;
-    }
-    array = (PyArrayObject *)input;
-
-    // check input array dimensions
-    if (PyArray_NDIM (array) != 1) {
-      PyErr_Format (PyExc_ValueError,
-          "input array has %d dimensions, not 1",
-          PyArray_NDIM (array));
-      goto fail;
-    } else {
-      if (vec->length != PyArray_SIZE (array)) {
-          PyErr_Format (PyExc_ValueError,
-                  "input array has length %d, but cvec has length %d",
-                  (int)PyArray_SIZE (array), vec->length);
-          goto fail;
-      }
-    }
-
-    Py_XDECREF(vec->phas);
-    vec->phas = input;
-    Py_INCREF(vec->phas);
-
-  } else {
-    PyErr_SetString (PyExc_ValueError, "can only accept array as input");
-    return 1;
-  }
-
+  if (!PyAubio_IsValidVector(input)) {
+    return 1;
+  }
+  long length = PyArray_SIZE ((PyArrayObject *)input);
+  if (length != vec->length) {
+    PyErr_Format (PyExc_ValueError,
+        "input array has length %ld, but cvec has length %d", length,
+        vec->length);
+    return 1;
+  }
+
+  Py_XDECREF(vec->phas);
+  vec->phas = input;
+  Py_INCREF(vec->phas);
   return 0;
-
-fail:
-  return 1;
 }
 
