Changeset 9775

Show
Ignore:
Timestamp:
10/10/08 21:45:09
Author:
jblum
Message:

support numpy types

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/trunk/grc/src/platforms/python/Param.py

    r9584 r9775  
    2121from .. base.Param import Param as _Param 
    2222import Constants 
     23import numpy 
    2324import os 
     25 
     26#define types, native python + numpy 
     27VECTOR_TYPES = (tuple, list, set, numpy.ndarray) 
     28COMPLEX_TYPES = [complex, numpy.complex, numpy.complex64, numpy.complex128] 
     29REAL_TYPES = [float, numpy.float, numpy.float32, numpy.float64] 
     30INT_TYPES = [int, long, numpy.int, numpy.int8, numpy.int16, numpy.int32, numpy.uint64, 
     31        numpy.uint, numpy.uint8, numpy.uint16, numpy.uint32, numpy.uint64] 
     32#cast to tuple for isinstance, concat subtypes 
     33COMPLEX_TYPES = tuple(COMPLEX_TYPES + REAL_TYPES + INT_TYPES) 
     34REAL_TYPES = tuple(REAL_TYPES + INT_TYPES) 
     35INT_TYPES = tuple(INT_TYPES) 
    2436 
    2537class Param(_Param): 
     
    115127                        if t == 'raw': return e 
    116128                        elif t == 'complex': 
    117                                 try: assert(isinstance(e, (complex, float, int, long))) 
     129                                try: assert(isinstance(e, COMPLEX_TYPES)) 
    118130                                except AssertionError: 
    119131                                        self._add_error_message('Expression "%s" is invalid for type complex.'%str(e)) 
     
    121133                                return e 
    122134                        elif t == 'real': 
    123                                 try: assert(isinstance(e, (float, int, long))) 
     135                                try: assert(isinstance(e, REAL_TYPES)) 
    124136                                except AssertionError: 
    125137                                        self._add_error_message('Expression "%s" is invalid for type real.'%str(e)) 
     
    127139                                return e 
    128140                        elif t == 'int': 
    129                                 try: assert(isinstance(e, (int, long))) 
     141                                try: assert(isinstance(e, INT_TYPES)) 
    130142                                except AssertionError: 
    131143                                        self._add_error_message('Expression "%s" is invalid for type integer.'%str(e)) 
    132144                                        raise Exception 
    133145                                return e 
     146                        ######################### 
     147                        # Numeric Vector Types 
     148                        ######################### 
    134149                        elif t == 'complex_vector': 
    135                                 if not isinstance(e, (tuple, list, set)): 
     150                                if not isinstance(e, VECTOR_TYPES): 
    136151                                        self._lisitify_flag = True 
    137152                                        e = [e] 
    138153                                try: 
    139154                                        for ei in e: 
    140                                                 assert(isinstance(ei, (complex, float, int, long))) 
     155                                                assert(isinstance(ei, COMPLEX_TYPES)) 
    141156                                except AssertionError: 
    142157                                        self._add_error_message('Expression "%s" is invalid for type complex vector.'%str(e)) 
     
    144159                                return e 
    145160                        elif t == 'real_vector': 
    146                                 if not isinstance(e, (tuple, list, set)): 
     161                                if not isinstance(e, VECTOR_TYPES): 
    147162                                        self._lisitify_flag = True 
    148163                                        e = [e] 
    149164                                try: 
    150165                                        for ei in e: 
    151                                                 assert(isinstance(ei, (float, int, long))) 
     166                                                assert(isinstance(ei, REAL_TYPES)) 
    152167                                except AssertionError: 
    153168                                        self._add_error_message('Expression "%s" is invalid for type real vector.'%str(e)) 
     
    155170                                return e 
    156171                        elif t == 'int_vector': 
    157                                 if not isinstance(e, (tuple, list, set)): 
     172                                if not isinstance(e, VECTOR_TYPES): 
    158173                                        self._lisitify_flag = True 
    159174                                        e = [e] 
    160175                                try: 
    161176                                        for ei in e: 
    162                                                 assert(isinstance(ei, (int, long))) 
     177                                                assert(isinstance(ei, INT_TYPES)) 
    163178                                except AssertionError: 
    164179                                        self._add_error_message('Expression "%s" is invalid for type integer vector.'%str(e)) 
  • gnuradio/trunk/grc/todo.txt

    r9772 r9775  
    55-ofdm wrappers 
    66-controlled step block 
    7 -throttle with sink only (source is nulled) 
    87-simplify simple usrp 
    9 -numbersink: update wrapper for newer api 
    108-probe: also non-float outputs 
    119 
     
    2321-click and drag on whitespace to scroll 
    2422-expand preferences, allow for custom prefs, prefs dialog should infer structure 
     23-drag connection to delete it 
    2524 
    2625##################################################