discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] PMT Oddities


From: Dave NotTelling
Subject: Re: [Discuss-gnuradio] PMT Oddities
Date: Tue, 22 Nov 2016 17:18:45 -0500

I ask because it feels like a bug.  Things like ((a . b), (c . d), (e . f)) are definitely not pairs (assuming a pair is 2 elements) and (in my opinion) should not return true for pmt.is_pair().

On Tue, Nov 22, 2016 at 5:12 PM, Dave NotTelling <address@hidden> wrote:
Martin,

     Was that done on purpose?  

     Thank you for the link!  I hadn't thought about checking that way.

Thanks!

-Dave

On Tue, Nov 22, 2016 at 5:08 PM, Martin Braun <address@hidden> wrote:
Dave,

pairs pass is_dict(), which is possibly the root cause here. See also:
https://github.com/gnuradio/gnuradio/blob/31b28f0cf4694378b26617616d08b4082668962f/gr-uhd/lib/usrp_block_impl.cc#L487-L494

Cheers,
M

On 11/22/2016 01:47 PM, Dave NotTelling wrote:
> I noticed today that the is_dict and is_pair checks are not appearing to
> work properly.  Here is an example that shows the issue:
>
> [code]
>
> #!/usr/bin/python
>
> import pmt
>
> def print_pmt(dictVar):
>     print 'isPair:%05s, isDict:%05s, isTuple:%05s  =>  %s' %
> (pmt.is_pair(dictVar), pmt.is_dict(dictVar), pmt.is_tuple(dictVar), dictVar)
>
> print 'DICT'
>
> d = pmt.make_dict()
> print_pmt(d)
>
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('b'))
> print_pmt(d)
>
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('d'))
> print_pmt(d)
>
> d = pmt.dict_add(d, pmt.intern('e'), pmt.intern('f'))
> print_pmt(d)
>
> print '\nCONS'
>
> p = pmt.cons(pmt.make_dict(), pmt.make_u8vector(0,0))
> print_pmt(p)
>
> [/code]
>
> Run that and you'll see what I consider strange behavior.  The values of
> is_pair and is_dict to not match what is expected.  Is that by design?
> If so, why?
>
> ((a . b)) is not a pair...  It's a single element dictionary
> ((c . d) (a . b)) i can sorta see this being a pair, but it wasn't
> created that way
> ((e . f) (c . d) (a . b)) definitely not a pair as it's 3 elements
>
> (() . #[]) don't dictionaries have to be nested?
>
>
> Thanks!
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>


_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio



reply via email to

[Prev in Thread] Current Thread [Next in Thread]