support numpy types
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 11 Oct 2008 03:45:09 +0000 (03:45 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Sat, 11 Oct 2008 03:45:09 +0000 (03:45 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9775 221aa14e-8319-0410-a670-987f0aec2ac5

grc/src/platforms/python/Param.py
grc/todo.txt

index 75098e9edaccf96ce2f8b119dae5d8bd7427a278..1381f6490b11c7789ff91ae874eb716102666506 100644 (file)
@@ -20,8 +20,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 from utils import expr_utils
 from .. base.Param import Param as _Param
 import Constants
+import numpy
 import os
 
+#define types, native python + numpy
+VECTOR_TYPES = (tuple, list, set, numpy.ndarray)
+COMPLEX_TYPES = [complex, numpy.complex, numpy.complex64, numpy.complex128]
+REAL_TYPES = [float, numpy.float, numpy.float32, numpy.float64]
+INT_TYPES = [int, long, numpy.int, numpy.int8, numpy.int16, numpy.int32, numpy.uint64,
+       numpy.uint, numpy.uint8, numpy.uint16, numpy.uint32, numpy.uint64]
+#cast to tuple for isinstance, concat subtypes
+COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES)
+REAL_TYPES = tuple(REAL_TYPES + INT_TYPES)
+INT_TYPES = tuple(INT_TYPES)
+
 class Param(_Param):
 
        _init = False
@@ -114,52 +126,55 @@ class Param(_Param):
                        #raise an exception if the data is invalid
                        if t == 'raw': return e
                        elif t == 'complex':
-                               try: assert(isinstance(e, (complex, float, int, long)))
+                               try: assert(isinstance(e, COMPLEX_TYPES))
                                except AssertionError:
                                        self._add_error_message('Expression "%s" is invalid for type complex.'%str(e))
                                        raise Exception
                                return e
                        elif t == 'real':
-                               try: assert(isinstance(e, (float, int, long)))
+                               try: assert(isinstance(e, REAL_TYPES))
                                except AssertionError:
                                        self._add_error_message('Expression "%s" is invalid for type real.'%str(e))
                                        raise Exception
                                return e
                        elif t == 'int':
-                               try: assert(isinstance(e, (int, long)))
+                               try: assert(isinstance(e, INT_TYPES))
                                except AssertionError:
                                        self._add_error_message('Expression "%s" is invalid for type integer.'%str(e))
                                        raise Exception
                                return e
+                       #########################
+                       # Numeric Vector Types
+                       #########################
                        elif t == 'complex_vector':
-                               if not isinstance(e, (tuple, list, set)):
+                               if not isinstance(e, VECTOR_TYPES):
                                        self._lisitify_flag = True
                                        e = [e]
                                try:
                                        for ei in e:
-                                               assert(isinstance(ei, (complex, float, int, long)))
+                                               assert(isinstance(ei, COMPLEX_TYPES))
                                except AssertionError:
                                        self._add_error_message('Expression "%s" is invalid for type complex vector.'%str(e))
                                        raise Exception
                                return e
                        elif t == 'real_vector':
-                               if not isinstance(e, (tuple, list, set)):
+                               if not isinstance(e, VECTOR_TYPES):
                                        self._lisitify_flag = True
                                        e = [e]
                                try:
                                        for ei in e:
-                                               assert(isinstance(ei, (float, int, long)))
+                                               assert(isinstance(ei, REAL_TYPES))
                                except AssertionError:
                                        self._add_error_message('Expression "%s" is invalid for type real vector.'%str(e))
                                        raise Exception
                                return e
                        elif t == 'int_vector':
-                               if not isinstance(e, (tuple, list, set)):
+                               if not isinstance(e, VECTOR_TYPES):
                                        self._lisitify_flag = True
                                        e = [e]
                                try:
                                        for ei in e:
-                                               assert(isinstance(ei, (int, long)))
+                                               assert(isinstance(ei, INT_TYPES))
                                except AssertionError:
                                        self._add_error_message('Expression "%s" is invalid for type integer vector.'%str(e))
                                        raise Exception
index 6c0629f9adb19d224f6c2fc50c534ca6b4549faf..249ecda42a432fbc3da93a373e0a692a92fd9b7b 100644 (file)
@@ -4,9 +4,7 @@
 -optparse block
 -ofdm wrappers
 -controlled step block
--throttle with sink only (source is nulled)
 -simplify simple usrp
--numbersink: update wrapper for newer api
 -probe: also non-float outputs
 
 ##################################################
@@ -22,6 +20,7 @@
 -search for blocks
 -click and drag on whitespace to scroll
 -expand preferences, allow for custom prefs, prefs dialog should infer structure
+-drag connection to delete it
 
 ##################################################
 # Problems