Hi all,
Is there a way to create a uniform PMT vector from python?
I can use, for example, ‘pmt.make_c32vector(length, value)’ to create
a vector where each element is ‘value’ but I don’t see a way to modify
these values from python.
If there isn’t, are there any objections to overloading these
functions to take std::vectors as input so that we can pass in lists
from python?
Cheers,
Ben
from python?
Cheers,
Ben
Hi,
I remember, I wasn’t sure about the supposed way of doing that either
for
a u8vector. Finally I used the set method to set the individual elements
like this:
elements as list
values = (0xA1, …)
create pmt vector with one default value for all elements
pmtvector = pmt.pmt_make_u8vector(len(values), 0x00)
set the individual elements
for i in xrange(len(values)) :
pmt.pmt_u8vector_set(pmtvector, i, values[i])
Great, thanks. I’m only using it for QA code so setting the elements
one by one like you suggest will work fine.
Yes, that’s perfect. Thanks.
On Thu, Apr 11, 2013 at 10:58 AM, Martin B. (CEL)
Hi Ben,
doesn’t pmt.to_pmt(LIST) do what you want?
Cheers,
MB
On Thu, Apr 11, 2013 at 10:03:21AM -0700, Ben R. wrote:
these values from python.
I remember, I wasn’t sure about the supposed way of doing that either for
for i in xrange(len(values)) :
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page
Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page
–
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)
Dipl.-Ing. Martin B.
Research Associate
Kaiserstraße 12
Building 05.01
76131 Karlsruhe
Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu
KIT – University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association
Just for the sake of anybody else who finds this mail thread when
searching.
Check out the file ‘pmt_to_python.py’ which resides at
‘gnuradio-runtime/python/pmt/pmt_to_python.py’ (the location pre-3.7
is different).
The two useful functions are:
pmt.to_pmt - Converts a python object to a PMT object.
pmt.python_to_pmt.python_to_pmt - Converts a PMT object to a python
object.
It can handle booleans, strings, integers, longs, floats, complex
numbers, dictionaries, lists and tuples.
I added a mention of these functions to the wiki.
On Thu, Apr 11, 2013 at 2:56 PM, Ben R. [email protected] wrote:
It can handle booleans, strings, integers, longs, floats, complex
numbers, dictionaries, lists and tuples.
I added a mention of these functions to the wiki.
Just FYI, the other way to do this is to use the “pmt.init_xxxvector”
call. It takes the number of items and list of items (as a Python
list) of the right data type as its arguments.
Tom