Merge branch 'fix/pyfvec'
[aubio.git] / python / lib / aubio / __init__.py
index 87a357d..98c913c 100644 (file)
@@ -30,7 +30,7 @@ from .midiconv import *
 from .slicing import *
 
 class fvec(numpy.ndarray):
-    """fvec(input_arg=1024, **kwargs)
+    """fvec(input_arg=1024)
     A vector holding float samples.
 
     If `input_arg` is an `int`, a 1-dimensional vector of length `input_arg`
@@ -43,16 +43,6 @@ class fvec(numpy.ndarray):
     input_arg : `int` or `array_like`
         Can be a positive integer, or any object that can be converted to
         a numpy array with :func:`numpy.array`.
-    **kwargs
-        Additional keyword arguments passed to :func:`numpy.zeros`, if
-        `input_arg` is an integer, or to :func:`numpy.array`. Should not
-        include `dtype`, which is already specified as
-        :data:`aubio.float_type`.
-
-    Returns
-    -------
-    numpy.ndarray
-        Array of shape `(length,)`.
 
     Examples
     --------
@@ -80,10 +70,15 @@ class fvec(numpy.ndarray):
     numpy.zeros : create a numpy array filled with zeros
     numpy.array : create a numpy array from an existing object
     """
-    def __new__(cls, input_arg=1024, **kwargs):
+    def __new__(cls, input_arg=1024):
         if isinstance(input_arg, int):
             if input_arg == 0:
                 raise ValueError("vector length of 1 or more expected")
-            return numpy.zeros(input_arg, dtype=float_type, **kwargs)
+            return numpy.zeros(input_arg, dtype=float_type, order='C')
         else:
-            return numpy.array(input_arg, dtype=float_type, **kwargs)
+            np_input = numpy.array(input_arg, dtype=float_type, order='C')
+            if len(np_input.shape) != 1:
+                raise ValueError("input_arg should have shape (n,)")
+            if np_input.shape[0] == 0:
+                raise ValueError("vector length of 1 or more expected")
+            return np_input