[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/15: set numpy_mappings -> dict, to fix p
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/15: set numpy_mappings -> dict, to fix py2.6 incompatibility |
Date: |
Thu, 10 Apr 2014 19:38:16 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 29a6b80f2f3b79fc27829d962475e2bbaf864fdf
Author: Marcus Müller <address@hidden>
Date: Sat Apr 5 15:00:16 2014 +0200
set numpy_mappings -> dict, to fix py2.6 incompatibility
---
gnuradio-runtime/python/pmt/pmt_to_python.py | 45 ++++++++++++++--------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/gnuradio-runtime/python/pmt/pmt_to_python.py
b/gnuradio-runtime/python/pmt/pmt_to_python.py
index 3c4dcf4..3da826a 100644
--- a/gnuradio-runtime/python/pmt/pmt_to_python.py
+++ b/gnuradio-runtime/python/pmt/pmt_to_python.py
@@ -63,35 +63,36 @@ def pmt_from_dict(p):
d = pmt.dict_add(d, python_to_pmt(k), python_to_pmt(v))
return d
+ #(numpy.float32,pmt.init_f32vector, float, pmt.f32vector_elements,
pmt.is_f32vector),
numpy_mappings = {
- (numpy.float32,pmt.init_f32vector, float, pmt.f32vector_elements,
pmt.is_f32vector),
- (numpy.float64,pmt.init_f64vector, float, pmt.f64vector_elements,
pmt.is_f64vector),
- (numpy.complex64,pmt.init_c32vector, complex, pmt.c32vector_elements,
pmt.is_c32vector),
- (numpy.complex128,pmt.init_c64vector, complex, pmt.c64vector_elements,
pmt.is_c64vector),
- (numpy.int8,pmt.init_s8vector, int, pmt.s8vector_elements,
pmt.is_s8vector),
- (numpy.int16,pmt.init_s16vector, int, pmt.s16vector_elements,
pmt.is_s16vector),
- (numpy.int32,pmt.init_s32vector, int, pmt.s32vector_elements,
pmt.is_s32vector),
-# (numpy.int64,pmt.init_s64vector, int, pmt.s64vector_elements,
pmt.is_s64vector),
- (numpy.uint8,pmt.init_u8vector, int, pmt.u8vector_elements,
pmt.is_u8vector),
- (numpy.uint16,pmt.init_u16vector, int, pmt.u16vector_elements,
pmt.is_u16vector),
- (numpy.uint32,pmt.init_u32vector, int, pmt.u32vector_elements,
pmt.is_u32vector),
-# (numpy.uint64,pmt.init_u64vector, int, pmt.u64vector_elements,
pmt.is_u64vector),
- (numpy.byte,pmt.init_u8vector, int, pmt.u8vector_elements,
pmt.is_u8vector),
+ numpy.float32: (pmt.init_f32vector, float, pmt.f32vector_elements,
pmt.is_f32vector),
+ numpy.float64: (pmt.init_f64vector, float, pmt.f64vector_elements,
pmt.is_f64vector),
+ numpy.complex64: (pmt.init_c32vector, complex, pmt.c32vector_elements,
pmt.is_c32vector),
+ numpy.complex128: (pmt.init_c64vector, complex, pmt.c64vector_elements,
pmt.is_c64vector),
+ numpy.int8: (pmt.init_s8vector, int, pmt.s8vector_elements,
pmt.is_s8vector),
+ numpy.int16: (pmt.init_s16vector, int, pmt.s16vector_elements,
pmt.is_s16vector),
+ numpy.int32: (pmt.init_s32vector, int, pmt.s32vector_elements,
pmt.is_s32vector),
+# numpy.int64: (pmt.init_s64vector, int, pmt.s64vector_elements,
pmt.is_s64vector),
+ numpy.uint8: (pmt.init_u8vector, int, pmt.u8vector_elements,
pmt.is_u8vector),
+ numpy.uint16: (pmt.init_u16vector, int, pmt.u16vector_elements,
pmt.is_u16vector),
+ numpy.uint32: (pmt.init_u32vector, int, pmt.u32vector_elements,
pmt.is_u32vector),
+# numpy.uint64: (pmt.init_u64vector, int, pmt.u64vector_elements,
pmt.is_u64vector),
+ numpy.byte: (pmt.init_u8vector, int, pmt.u8vector_elements,
pmt.is_u8vector),
}
def numpy_to_uvector(p):
- if not p.dtype in map(lambda x: x[0], numpy_mappings):
+ try:
+ mapping = numpy_mappings
+ pc = map(mapping[1], p)
+ return mapping[0](p.size, pc)
+ except KeyError:
raise ValueError("unsupported numpy array dtype for converstion to pmt
%s"%(p.dtype))
- for m in numpy_mappings:
- if(m[0] == p.dtype):
- pc = map(lambda i: m[2](i), p)
- return m[1](p.size, pc);
def uvector_to_numpy(p):
- for m in numpy_mappings:
- if(m[4](p)):
- a= m[3](p);
- return numpy.array(m[3](p), dtype=m[0]);
+ for key in numpy_mappings:
+ m = numpy_mappings[key]
+ if(m[3](p)):
+ return numpy.array(m[2](p), dtype=key);
raise ValueError("unsupported numpy array dtype for converstion from pmt
%s"%(p))
THE_TABLE = ( #python type, check pmt type, to python, from python
- [Commit-gnuradio] [gnuradio] branch master updated (cd06fdc -> 4b55c7f), git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 12/15: digital: white space removal., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 10/15: grc: validate params only on focus-out, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 11/15: Merge remote-tracking branch 'mmueller/pmt_to_python-py2.6-compat', git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 06/15: Merge branch 'master' of github:gnuradio/gnuradio into pmt_to_python-py2.6-compat, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 02/15: qtgui: fixing up some minor parameters., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 09/15: grc: move FileParam to gui module, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 05/15: renamed and cleaned up a bit, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 04/15: pmt_to_python: numpy_to_uvector and reverse works, QA added, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 01/15: set numpy_mappings -> dict, to fix py2.6 incompatibility,
git <=
- [Commit-gnuradio] [gnuradio] 07/15: grc: adding param templates, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 03/15: volk: changes QA code to use volk_malloc and volk_free., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 14/15: digital: fix for issue #663., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 15/15: digital: updated test_corr_and_sync to give time sink lines default labels., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 13/15: digital: fix for issue #664., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 08/15: qtgui: changing line config params to use base_key to make cleaner., git, 2014/04/10