shithub: aubio

Download patch

ref: 143682ba94bf859c8bf730650e52af15addb7d00
parent: 016813e9c9025d8fc805a36d24771e3bc586fa05
author: Paul Brossier <piem@piem.org>
date: Tue May 10 17:37:37 EDT 2016

python/lib/aubio/__init__.py: clean up, use isinstance

--- a/python/lib/aubio/__init__.py
+++ b/python/lib/aubio/__init__.py
@@ -6,10 +6,10 @@
 from .slicing import *
 
 class fvec(numpy.ndarray):
-    """a simple numpy array holding a vector of %s""" % float_type
+    """a numpy vector holding audio samples"""
 
-    def __new__(self, length = 1024, **kwargs):
-        self.length = length
-        if type(length) == type([]):
-            return numpy.array(length, dtype = float_type, **kwargs)
-        return numpy.zeros(length, dtype = float_type, **kwargs)
+    def __new__(cls, input_arg=1024, **kwargs):
+        if isinstance(input_arg, int):
+            return numpy.zeros(input_arg, dtype=float_type, **kwargs)
+        else:
+            return numpy.array(input_arg, dtype=float_type, **kwargs)