What should is if you use strings to initialize the data type, in_sig = [numpy.dtype(string_passed_via_constructor_argument)]
and use an option field that gives you "uint16", "float32", "byte", "complex64"… Cheers, Marcus On 13.05.2016 18:13, Martin Braun wrote: > You can definitely do that. Passing in some numeric or string value as > the type to your block and then mapping to the correct numpy type would > definitely work. Maybe you can even select numpy types from a GRC file, > not sure if a GRC enum will allow you to choose numpy types. > > M > > On 05/12/2016 03:16 PM, Richard Bell wrote: >> Martin, >> >> I like the first idea. Would it be possible to create a new variable in >> the xml file that is assigned numpy.float32 when the user selects the >> float option, or is assigned numpy.complex64 when the user selects the >> complex option? Another words, I don't want the user to have to select >> the port type AND have to type in the python type of the port, that >> should be clear from the port type drop down selection. I'm just not >> sure how to work this in the xml file, or if its even possible. >> >> Rich >> >> On Thu, May 12, 2016 at 11:11 AM, Martin Braun <[email protected] >> <mailto:[email protected]>> wrote: >> >> You can either make this a block argument (i.e., you ask the user to >> pass in numpy.float32 or whatever), or, to keep consistent with the C++ >> way of doing things, you can make a block argument called 'sizeof' and >> then create a dict that maps sizes to numpy.<FOO> values, and use that >> to set in_sig. >> >> M >> >> On 05/11/2016 02:04 PM, Richard Bell wrote: >> > I've created a python based OOT block and I want to give the user the >> > ability to select the input/output type. I know how to do this for C++ >> > based blocks, but I'm stuck on what to do with the python blocks >> > signature, as it doesn't ask for the item_size like the C++ blocks >> do. I >> > have to give it something explicit like >> > >> > in_sig = [numpy.float32] >> > >> > How do I write the generic sig that depends on what the user >> selected in >> > GRC? >> > >> > Note: The algorithm in the body of this block doesn't change depending >> > on type selected. It's a simple block. >> > >> > Thanks, >> > Rich >> > >> > >> > _______________________________________________ >> > Discuss-gnuradio mailing list >> > [email protected] <mailto:[email protected]> >> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio >> > >> >> >> _______________________________________________ >> Discuss-gnuradio mailing list >> [email protected] <mailto:[email protected]> >> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio >> >> > > _______________________________________________ > Discuss-gnuradio mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio _______________________________________________ Discuss-gnuradio mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
