Re: [Discuss-gnuradio] PMT Oddities

2016-12-13 Thread Martin Braun
I'd agree that your code is not behaving as expected. Don't have
something off the top of my head though :/

M

On 12/13/2016 02:51 PM, Dave NotTelling wrote:
> Assuming that is reproducible, does anyone have suggestions on how to
> get around it?
> 
> On Fri, Dec 9, 2016 at 9:16 PM, Dave NotTelling  > wrote:
> 
> Here is a full example:
> 
> [code]
> 
> #!/usr/bin/python
> 
> import pmt
> 
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
> 
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
> 
> print 'dict_keys with a populated dictionary'
> print pmt.dict_keys(a)
> 
> a = pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10))
> 
> print 'dict_keys with an empty dictionary'
> print pmt.dict_keys(a)
> 
> [/code]
> 
> You end up with the following output:
> 
> [output]
> 
> dict_keys with a populated dictionary
> ((c . c))
> dict_keys with an empty dictionary
> Traceback (most recent call last):
>   File "test.py", line 18, in 
> print pmt.dict_keys(a)
>   File "/usr/local/lib/python2.7/dist-packages/pmt/pmt_swig.py",
> line 3010, in dict_keys
> return _pmt_swig.dict_keys(dict)
> RuntimeError: pmt_car: wrong_type : ()
> 
> 
> [/output]
> 
> The first call to dict_keys(a) returns the last element in the
> dictionary.  The second call errors out.  Both should error out correct?
> 
> On Fri, Dec 9, 2016 at 9:11 PM, Dave NotTelling  > wrote:
> 
> I understand that it should bomb, but it doesn't if there are
> elements in the dictionary of the pair generated by cons.
>  that's the problem.  calling dict_keys should die on both
> tests, but returns just fine on the first test. 
> 
> 
> On Dec 9, 2016 1:35 PM, "Martin Braun"  > wrote:
> 
> On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> > Marcus & Martin:
> >
> >  I tried the dict_keys() method of checking, but even
> that can
> > fail.  Here is an example:
> >
> > [code]
> >
> > import pmt
> >
> > d = pmt.make_dict()
> > d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> > d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> > d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
> >
> > a = pmt.cons(d, pmt.make_u8vector(10, 10))
> >
> > print pmt.dict_keys(a)
> >
> > [/code]
> >
> > You end up with: ((c . c))
> >
> > The dict_keys() method will bomb if there are no elements
> in the dictionary:
> >
> > print pmt.dict_keys(pmt.cons(pmt.make_dict(),
> pmt.make_u8vector(10, 10)))
> 
> It's supposed to bomb -- pmt.cons() does not return a dict.
> That's
> exactly how you can test for dicts.
> 
> See:
> 
> https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494
> 
> 
> 
> -- M
> 
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org 
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> 
> 
> 
> 


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


Re: [Discuss-gnuradio] PMT Oddities

2016-12-13 Thread Dave NotTelling
Assuming that is reproducible, does anyone have suggestions on how to get
around it?

On Fri, Dec 9, 2016 at 9:16 PM, Dave NotTelling  wrote:

> Here is a full example:
>
> [code]
>
> #!/usr/bin/python
>
> import pmt
>
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
>
> print 'dict_keys with a populated dictionary'
> print pmt.dict_keys(a)
>
> a = pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10))
>
> print 'dict_keys with an empty dictionary'
> print pmt.dict_keys(a)
>
> [/code]
>
> You end up with the following output:
>
> [output]
>
> dict_keys with a populated dictionary
> ((c . c))
> dict_keys with an empty dictionary
> Traceback (most recent call last):
>   File "test.py", line 18, in 
> print pmt.dict_keys(a)
>   File "/usr/local/lib/python2.7/dist-packages/pmt/pmt_swig.py", line
> 3010, in dict_keys
> return _pmt_swig.dict_keys(dict)
> RuntimeError: pmt_car: wrong_type : ()
>
>
> [/output]
>
> The first call to dict_keys(a) returns the last element in the
> dictionary.  The second call errors out.  Both should error out correct?
>
> On Fri, Dec 9, 2016 at 9:11 PM, Dave NotTelling 
> wrote:
>
>> I understand that it should bomb, but it doesn't if there are elements in
>> the dictionary of the pair generated by cons.  that's the problem.  calling
>> dict_keys should die on both tests, but returns just fine on the first
>> test.
>>
>>
>> On Dec 9, 2016 1:35 PM, "Martin Braun"  wrote:
>>
>> On 12/05/2016 01:56 PM, Dave NotTelling wrote:
>> > Marcus & Martin:
>> >
>> >  I tried the dict_keys() method of checking, but even that can
>> > fail.  Here is an example:
>> >
>> > [code]
>> >
>> > import pmt
>> >
>> > d = pmt.make_dict()
>> > d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
>> > d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
>> > d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>> >
>> > a = pmt.cons(d, pmt.make_u8vector(10, 10))
>> >
>> > print pmt.dict_keys(a)
>> >
>> > [/code]
>> >
>> > You end up with: ((c . c))
>> >
>> > The dict_keys() method will bomb if there are no elements in the
>> dictionary:
>> >
>> > print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10,
>> 10)))
>>
>> It's supposed to bomb -- pmt.cons() does not return a dict. That's
>> exactly how you can test for dicts.
>>
>> See:
>> https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b4
>> 8fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494
>>
>> -- M
>>
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>>
>>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-12-09 Thread Dave NotTelling
Here is a full example:

[code]

#!/usr/bin/python

import pmt

d = pmt.make_dict()
d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))

a = pmt.cons(d, pmt.make_u8vector(10, 10))

print 'dict_keys with a populated dictionary'
print pmt.dict_keys(a)

a = pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10))

print 'dict_keys with an empty dictionary'
print pmt.dict_keys(a)

[/code]

You end up with the following output:

[output]

dict_keys with a populated dictionary
((c . c))
dict_keys with an empty dictionary
Traceback (most recent call last):
  File "test.py", line 18, in 
print pmt.dict_keys(a)
  File "/usr/local/lib/python2.7/dist-packages/pmt/pmt_swig.py", line 3010,
in dict_keys
return _pmt_swig.dict_keys(dict)
RuntimeError: pmt_car: wrong_type : ()


[/output]

The first call to dict_keys(a) returns the last element in the dictionary.
The second call errors out.  Both should error out correct?

On Fri, Dec 9, 2016 at 9:11 PM, Dave NotTelling  wrote:

> I understand that it should bomb, but it doesn't if there are elements in
> the dictionary of the pair generated by cons.  that's the problem.  calling
> dict_keys should die on both tests, but returns just fine on the first
> test.
>
>
> On Dec 9, 2016 1:35 PM, "Martin Braun"  wrote:
>
> On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> > Marcus & Martin:
> >
> >  I tried the dict_keys() method of checking, but even that can
> > fail.  Here is an example:
> >
> > [code]
> >
> > import pmt
> >
> > d = pmt.make_dict()
> > d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> > d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> > d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
> >
> > a = pmt.cons(d, pmt.make_u8vector(10, 10))
> >
> > print pmt.dict_keys(a)
> >
> > [/code]
> >
> > You end up with: ((c . c))
> >
> > The dict_keys() method will bomb if there are no elements in the
> dictionary:
> >
> > print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10,
> 10)))
>
> It's supposed to bomb -- pmt.cons() does not return a dict. That's
> exactly how you can test for dicts.
>
> See:
> https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b4
> 8fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494
>
> -- M
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-12-09 Thread Dave NotTelling
I understand that it should bomb, but it doesn't if there are elements in
the dictionary of the pair generated by cons.  that's the problem.  calling
dict_keys should die on both tests, but returns just fine on the first
test.

On Dec 9, 2016 1:35 PM, "Martin Braun"  wrote:

On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> Marcus & Martin:
>
>  I tried the dict_keys() method of checking, but even that can
> fail.  Here is an example:
>
> [code]
>
> import pmt
>
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
>
> print pmt.dict_keys(a)
>
> [/code]
>
> You end up with: ((c . c))
>
> The dict_keys() method will bomb if there are no elements in the
dictionary:
>
> print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))

It's supposed to bomb -- pmt.cons() does not return a dict. That's
exactly how you can test for dicts.

See:
https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50a
b5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494

-- M

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


Re: [Discuss-gnuradio] PMT Oddities

2016-12-09 Thread Martin Braun
On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> Marcus & Martin:
> 
>  I tried the dict_keys() method of checking, but even that can
> fail.  Here is an example:
> 
> [code]
> 
> import pmt
> 
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
> 
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
> 
> print pmt.dict_keys(a)
> 
> [/code]
> 
> You end up with: ((c . c))
> 
> The dict_keys() method will bomb if there are no elements in the dictionary:
> 
> print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))

It's supposed to bomb -- pmt.cons() does not return a dict. That's
exactly how you can test for dicts.

See:
https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494

-- M

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


Re: [Discuss-gnuradio] PMT Oddities

2016-12-07 Thread Dave NotTelling
Thoughts?

On Mon, Dec 5, 2016 at 4:56 PM, Dave NotTelling  wrote:

> Marcus & Martin:
>
>  I tried the dict_keys() method of checking, but even that can fail.
> Here is an example:
>
> [code]
>
> import pmt
>
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
>
> print pmt.dict_keys(a)
>
> [/code]
>
> You end up with: ((c . c))
>
> The dict_keys() method will bomb if there are no elements in the
> dictionary:
>
> print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))
>
>
> On Tue, Nov 22, 2016 at 5:55 PM, Dave NotTelling 
> wrote:
>
>> Thanks for the explanation!
>>
>> On Tue, Nov 22, 2016 at 5:29 PM, Marcus Müller 
>> wrote:
>>
>>> That's a long story. Essentially, a list is a pair of the first element
>>> and a pair of a second element and a pair of the third element and a pair
>>> of …
>>>
>>> Cheers,
>>> Marcus
>>>
>>> On 22.11.2016 23:18, Dave NotTelling wrote:
>>>
>>> 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 
>>> 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 
 wrote:

> Dave,
>
> pairs pass is_dict(), which is possibly the root cause here. See also:
> https://github.com/gnuradio/gnuradio/blob/31b28f0cf4694378b2
> 6617616d08b4082668962f/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
> > Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>


>>>
>>>
>>> ___
>>> Discuss-gnuradio mailing 
>>> listDiscuss-gnuradio@gnu.orghttps://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>
>>>
>>>
>>> ___
>>> Discuss-gnuradio mailing list
>>> Discuss-gnuradio@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>
>>>
>>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-12-05 Thread Dave NotTelling
Marcus & Martin:

 I tried the dict_keys() method of checking, but even that can fail.
Here is an example:

[code]

import pmt

d = pmt.make_dict()
d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))

a = pmt.cons(d, pmt.make_u8vector(10, 10))

print pmt.dict_keys(a)

[/code]

You end up with: ((c . c))

The dict_keys() method will bomb if there are no elements in the dictionary:

print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))


On Tue, Nov 22, 2016 at 5:55 PM, Dave NotTelling 
wrote:

> Thanks for the explanation!
>
> On Tue, Nov 22, 2016 at 5:29 PM, Marcus Müller 
> wrote:
>
>> That's a long story. Essentially, a list is a pair of the first element
>> and a pair of a second element and a pair of the third element and a pair
>> of …
>>
>> Cheers,
>> Marcus
>>
>> On 22.11.2016 23:18, Dave NotTelling wrote:
>>
>> 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 
>> 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 
>>> wrote:
>>>
 Dave,

 pairs pass is_dict(), which is possibly the root cause here. See also:
 https://github.com/gnuradio/gnuradio/blob/31b28f0cf4694378b2
 6617616d08b4082668962f/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
 > Discuss-gnuradio@gnu.org
 > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
 >


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

>>>
>>>
>>
>>
>> ___
>> Discuss-gnuradio mailing 
>> listDiscuss-gnuradio@gnu.orghttps://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>>
>>
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-11-22 Thread Dave NotTelling
Thanks for the explanation!

On Tue, Nov 22, 2016 at 5:29 PM, Marcus Müller 
wrote:

> That's a long story. Essentially, a list is a pair of the first element
> and a pair of a second element and a pair of the third element and a pair
> of …
>
> Cheers,
> Marcus
>
> On 22.11.2016 23:18, Dave NotTelling wrote:
>
> 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 
> 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 
>> wrote:
>>
>>> Dave,
>>>
>>> pairs pass is_dict(), which is possibly the root cause here. See also:
>>> https://github.com/gnuradio/gnuradio/blob/31b28f0cf4694378b2
>>> 6617616d08b4082668962f/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
>>> > Discuss-gnuradio@gnu.org
>>> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>> >
>>>
>>>
>>> ___
>>> Discuss-gnuradio mailing list
>>> Discuss-gnuradio@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>>
>>
>>
>
>
> ___
> Discuss-gnuradio mailing 
> listDiscuss-gnuradio@gnu.orghttps://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-11-22 Thread Marcus Müller
That's a long story. Essentially, a list is a pair of the first element
and a pair of a second element and a pair of the third element and a
pair of …

Cheers,
Marcus


On 22.11.2016 23:18, Dave NotTelling wrote:
> 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  > 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
> > 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
> > Discuss-gnuradio@gnu.org 
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> >
>
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org 
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
>
>
>
>
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

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


Re: [Discuss-gnuradio] PMT Oddities

2016-11-22 Thread Martin Braun
I remember writing this (UHD code), and at the time, I thought I could
fix PMTs first, but then decided it was too invasive. I would have to go
over the exercise again to tell you exactly why.

You're right, it feels like a bug. Probably, this was not by design, but
is an artefact of how PMT types have their roots in LISPy types, which
have pairs, but not dictionaries as such.

Cheers,
M

On 11/22/2016 02:18 PM, Dave NotTelling wrote:
> 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  > 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
> > 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
> > Discuss-gnuradio@gnu.org 
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> >
> 
> 
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org 
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> 
> 
> 


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


Re: [Discuss-gnuradio] PMT Oddities

2016-11-22 Thread Dave NotTelling
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 
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 
> wrote:
>
>> Dave,
>>
>> pairs pass is_dict(), which is possibly the root cause here. See also:
>> https://github.com/gnuradio/gnuradio/blob/31b28f0cf4694378b2
>> 6617616d08b4082668962f/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
>> > Discuss-gnuradio@gnu.org
>> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>> >
>>
>>
>> ___
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-11-22 Thread Dave NotTelling
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 
wrote:

> Dave,
>
> pairs pass is_dict(), which is possibly the root cause here. See also:
> https://github.com/gnuradio/gnuradio/blob/31b28f0cf4694378b26617616d08b4
> 082668962f/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
> > Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
>
> ___
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] PMT Oddities

2016-11-22 Thread Martin Braun
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
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 


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