buggy dictionary [message #91129] |
Mon, 08 June 2015 07:08  |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi,
I've just encountered another bug using dictionaries.
This is ok:
IDL> a = dictionary('b',findgen(10))
IDL> print, a['b',1:-1]
1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000
Doing the same, but inside an object (that being self.a['b',1:-1]) will make the IDLDE crash "hard" (=window closes without warning).
Here is an example:
pro testObjBug::testIt
print, self.aa['b',1:-1] ;this makes IDL crash
end
function testObjBug::init
self.aa = dictionary('b',findgen(10))
return, 1
end
pro testObjBug__define
class = {testObjBug,$
aa:obj_new()}
end
pro testObjBug
o = obj_new('testObjBug')
o->testIt
end
The only way around this is to copy the variable out of the object:
aa = self.aa['b']
print, aa[2:-2]
Cheers,
Helder
PS: I've submitted this to IDL. It's logged with incident nr 294397.
|
|
|
Re: buggy dictionary [message #91130 is a reply to message #91129] |
Mon, 08 June 2015 07:15   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Monday, June 8, 2015 at 4:08:30 PM UTC+2, Helder wrote:
> Hi,
> I've just encountered another bug using dictionaries.
>
> This is ok:
> IDL> a = dictionary('b',findgen(10))
> IDL> print, a['b',1:-1]
> 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000
>
> Doing the same, but inside an object (that being self.a['b',1:-1]) will make the IDLDE crash "hard" (=window closes without warning).
> Here is an example:
>
> pro testObjBug::testIt
> print, self.aa['b',1:-1] ;this makes IDL crash
> end
>
> function testObjBug::init
> self.aa = dictionary('b',findgen(10))
> return, 1
> end
>
> pro testObjBug__define
> class = {testObjBug,$
> aa:obj_new()}
> end
>
> pro testObjBug
> o = obj_new('testObjBug')
> o->testIt
> end
>
> The only way around this is to copy the variable out of the object:
> aa = self.aa['b']
> print, aa[2:-2]
>
> Cheers,
> Helder
>
> PS: I've submitted this to IDL. It's logged with incident nr 294397.
Sorry, but I just managed to make a much shorter example of this bug. Please save everything before trying it!
IDL> a = dictionary('b',dictionary('c',findgen(10)))
IDL> a.b['c',1:-1]
... bye bye IDL
Notice that this works:
IDL> a.b['c',1:9]
1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000 7.0000000 8.0000000 9.0000000
But anything with the '-' after the ':' doesn't.
Cheers,
Helder
|
|
|
|
Re: buggy dictionary [message #91132 is a reply to message #91131] |
Mon, 08 June 2015 08:12   |
dg86
Messages: 118 Registered: September 2012
|
Senior Member |
|
|
On Monday, June 8, 2015 at 10:49:14 AM UTC-4, Fabien wrote:
> On 06/08/2015 04:15 PM, Helder wrote:
>> Please save everything before trying it!
>>
>> IDL> a = dictionary('b',dictionary('c',findgen(10)))
>> IDL> a.b['c',1:-1]
>>
>> ... bye bye IDL
>
> Nice! Crashes IDL on my 64b Linux machine, too.
>
> Cheers,
>
> Fabien
Same is true for MacOS. Attempting a slice with a negative index gives the
correct answer, but leaves IDL churning. After a few seconds, IDL crashes with
Segmentation fault: 11
Cool!
|
|
|
|
|
Re: buggy dictionary [message #91138 is a reply to message #91131] |
Mon, 08 June 2015 11:28   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
On Monday, 8 June 2015 07:49:14 UTC-7, Fabien wrote:
> On 06/08/2015 04:15 PM, Helder wrote:
>> Please save everything before trying it!
>>
>> IDL> a = dictionary('b',dictionary('c',findgen(10)))
>> IDL> a.b['c',1:-1]
>>
>> ... bye bye IDL
>
> Nice! Crashes IDL on my 64b Linux machine, too.
>
> Cheers,
>
> Fabien
I found some slightly different results:
IDL> !version
{
"ARCH": "x86_64",
"OS": "Win32",
"OS_FAMILY": "Windows",
"OS_NAME": "MicrosoftWindows",
"RELEASE": "8.4",
"BUILD_DATE": "Sep272014",
"MEMORY_BITS": 64,
"FILE_OFFSET_BITS": 64
}
IDL> a = dictionary('b',dictionary('c',findgen(10)))
IDL> a.b['c',[1:-1]]
1.0000000 0.00000000 0.00000000
;; Mine does not fail like yours, but it seems wrong!
;; That looks like array indexing off the low end, filling in '0' as it reaches back to -1
;; This seems to get to what you want, I think!:
IDL> a.b.c[1:-1]
1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
7.0000000 8.0000000 9.0000000
;; But maybe you want the 'c' to be a string, to change it programmatically, in which case:
IDL> (a.b['c'])[1:-1]
1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
7.0000000 8.0000000 9.0000000
;; I believe the parentheses cause a temporary copy of the array(10) to be made, which may not be OK in your application
;; I wondered about modifying values in there, doesn't look good:
IDL> a.b.c[1:-1]=42
% Attempt to store into an expression: Structure reference.
% Execution halted at: $MAIN$
IDL> help,a.b.c[1:-1]
<Expression> FLOAT = Array[9]
;; I would think that should work, too:
IDL> c=findgen(10)
IDL> c[1:-1]=42
IDL> c
0.00000000 42.000000 42.000000 42.000000 42.000000 42.000000
42.000000 42.000000 42.000000 42.000000
Is anyone from {Harr|Exel}|is taking notes from this? Chris, are you there? :-)
Cheers,
-Dick
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
|
|
|
Re: buggy dictionary [message #91139 is a reply to message #91138] |
Mon, 08 June 2015 13:30   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Monday, June 8, 2015 at 8:28:59 PM UTC+2, Dick Jackson wrote:
> On Monday, 8 June 2015 07:49:14 UTC-7, Fabien wrote:
>> On 06/08/2015 04:15 PM, Helder wrote:
>>> Please save everything before trying it!
>>>
>>> IDL> a = dictionary('b',dictionary('c',findgen(10)))
>>> IDL> a.b['c',1:-1]
>>>
>>> ... bye bye IDL
>>
>> Nice! Crashes IDL on my 64b Linux machine, too.
>>
>> Cheers,
>>
>> Fabien
>
> I found some slightly different results:
>
> IDL> !version
> {
> "ARCH": "x86_64",
> "OS": "Win32",
> "OS_FAMILY": "Windows",
> "OS_NAME": "MicrosoftWindows",
> "RELEASE": "8.4",
> "BUILD_DATE": "Sep272014",
> "MEMORY_BITS": 64,
> "FILE_OFFSET_BITS": 64
> }
>
> IDL> a = dictionary('b',dictionary('c',findgen(10)))
>
> IDL> a.b['c',[1:-1]]
> 1.0000000 0.00000000 0.00000000
> ;; Mine does not fail like yours, but it seems wrong!
> ;; That looks like array indexing off the low end, filling in '0' as it reaches back to -1
>
> ;; This seems to get to what you want, I think!:
> IDL> a.b.c[1:-1]
> 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
> 7.0000000 8.0000000 9.0000000
> ;; But maybe you want the 'c' to be a string, to change it programmatically, in which case:
> IDL> (a.b['c'])[1:-1]
> 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
> 7.0000000 8.0000000 9.0000000
> ;; I believe the parentheses cause a temporary copy of the array(10) to be made, which may not be OK in your application
>
> ;; I wondered about modifying values in there, doesn't look good:
> IDL> a.b.c[1:-1]=42
> % Attempt to store into an expression: Structure reference.
> % Execution halted at: $MAIN$
> IDL> help,a.b.c[1:-1]
> <Expression> FLOAT = Array[9]
>
> ;; I would think that should work, too:
> IDL> c=findgen(10)
> IDL> c[1:-1]=42
> IDL> c
> 0.00000000 42.000000 42.000000 42.000000 42.000000 42.000000
> 42.000000 42.000000 42.000000 42.000000
>
> Is anyone from {Harr|Exel}|is taking notes from this? Chris, are you there? :-)
>
> Cheers,
> -Dick
>
> Dick Jackson Software Consulting Inc.
> Victoria, BC, Canada --- http://www.d-jackson.com
Hi,
I got some feedback from Exelis, but it's way past working hours so I will sum up tomorrow.
Dick, you're right. There is a bug.
Cheers,
Helder
|
|
|
Re: buggy dictionary [message #91144 is a reply to message #91138] |
Tue, 09 June 2015 02:32   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Monday, June 8, 2015 at 8:28:59 PM UTC+2, Dick Jackson wrote:
> On Monday, 8 June 2015 07:49:14 UTC-7, Fabien wrote:
>> On 06/08/2015 04:15 PM, Helder wrote:
>>> Please save everything before trying it!
>>>
>>> IDL> a = dictionary('b',dictionary('c',findgen(10)))
>>> IDL> a.b['c',1:-1]
>>>
>>> ... bye bye IDL
>>
>> Nice! Crashes IDL on my 64b Linux machine, too.
>>
>> Cheers,
>>
>> Fabien
>
> I found some slightly different results:
>
> IDL> !version
> {
> "ARCH": "x86_64",
> "OS": "Win32",
> "OS_FAMILY": "Windows",
> "OS_NAME": "MicrosoftWindows",
> "RELEASE": "8.4",
> "BUILD_DATE": "Sep272014",
> "MEMORY_BITS": 64,
> "FILE_OFFSET_BITS": 64
> }
>
> IDL> a = dictionary('b',dictionary('c',findgen(10)))
>
> IDL> a.b['c',[1:-1]]
> 1.0000000 0.00000000 0.00000000
> ;; Mine does not fail like yours, but it seems wrong!
> ;; That looks like array indexing off the low end, filling in '0' as it reaches back to -1
>
> ;; This seems to get to what you want, I think!:
> IDL> a.b.c[1:-1]
> 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
> 7.0000000 8.0000000 9.0000000
> ;; But maybe you want the 'c' to be a string, to change it programmatically, in which case:
> IDL> (a.b['c'])[1:-1]
> 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
> 7.0000000 8.0000000 9.0000000
> ;; I believe the parentheses cause a temporary copy of the array(10) to be made, which may not be OK in your application
>
> ;; I wondered about modifying values in there, doesn't look good:
> IDL> a.b.c[1:-1]=42
> % Attempt to store into an expression: Structure reference.
> % Execution halted at: $MAIN$
> IDL> help,a.b.c[1:-1]
> <Expression> FLOAT = Array[9]
>
> ;; I would think that should work, too:
> IDL> c=findgen(10)
> IDL> c[1:-1]=42
> IDL> c
> 0.00000000 42.000000 42.000000 42.000000 42.000000 42.000000
> 42.000000 42.000000 42.000000 42.000000
>
> Is anyone from {Harr|Exel}|is taking notes from this? Chris, are you there? :-)
>
> Cheers,
> -Dick
>
> Dick Jackson Software Consulting Inc.
> Victoria, BC, Canada --- http://www.d-jackson.com
Hi Dick,
you're absolutely right. There is a syntax error that causes the crash.
From IDL support I learned that I should have used the following syntax to index the array::
a = dictionary('b',dictionary('c',findgen(10)))
print, a.b['c',[1:-1]]
However, as you pointed out, this delivers the wrong answer. Exelis acknowledged this (incident number 294397) and filed a bug report.
So this will give a wrong answer:
print, a.b['c',[1:-1]]
but this will be ok:
print, a.b.c[1:-1]
Cheers,
Helder
PS: Funny extra. According to the dictionary access documentation (http://www.exelisvis.com/docs/DICTIONARY.html#Access) in the example at the very button there is a code example:
------------------------------------------------------------
str = {data: FINDGEN(10)}
PRINT, str.data
PRINT, str.data[2:5] ; this works
dict = DICTIONARY('data', FINDGEN(10))
PRINT, dict.data ; this works
PRINT, dict.data[2:5] ; this will fail with an error
PRINT, dict['data', [2:5]] ; this works correctly
----------------------------------------------------------
The line commented "this will fail with an error" does not fail at all.
IDL> dict = DICTIONARY('data', FINDGEN(10))
IDL> PRINT, dict.data ; this works
IDL> PRINT, dict.data[2:5] ; this will fail with an error
IDL> PRINT, dict['data', [2:5]] ; this works correctly
0.000000 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000
2.00000 3.00000 4.00000 5.00000
2.00000 3.00000 4.00000 5.00000
IDL> !version
{
"ARCH": "x86_64",
"OS": "Win32",
"OS_FAMILY": "Windows",
"OS_NAME": "Microsoft Windows",
"RELEASE": "8.4.1",
"BUILD_DATE": "Feb 17 2015",
"MEMORY_BITS": 64,
"FILE_OFFSET_BITS": 64
}
|
|
|
Re: buggy dictionary [message #91145 is a reply to message #91144] |
Tue, 09 June 2015 04:01   |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Tuesday, June 9, 2015 at 11:32:30 AM UTC+2, Helder wrote:
>
> a = dictionary('b',dictionary('c',findgen(10)))
> print, a.b['c',[1:-1]]
>
> However, as you pointed out, this delivers the wrong answer. Exelis acknowledged this (incident number 294397) and filed a bug report.
>
> So this will give a wrong answer:
> print, a.b['c',[1:-1]]
Here [1:-1] is not a subscript range, it is the colon operator for array creation (introduced in IDL 8.3):
IDL> x=[1:-1]
IDL> help, x & print, x
X INT = Array[3]
1 0 -1
So [1:-1] is actually an array subscript (with the usual array subscript clipping).
> but this will be ok:
> print, a.b.c[1:-1]
Here [1:-1] is a subscript range with a negative subscript value.
So the two [1:-1]'s have different meaning.
regards,
Lajos
|
|
|
Re: buggy dictionary [message #91155 is a reply to message #91145] |
Tue, 09 June 2015 09:10   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
On Tuesday, 9 June 2015 04:01:43 UTC-7, fawltyl...@gmail.com wrote:
> On Tuesday, June 9, 2015 at 11:32:30 AM UTC+2, Helder wrote:
>>
>> a = dictionary('b',dictionary('c',findgen(10)))
>> print, a.b['c',[1:-1]]
>>
>> However, as you pointed out, this delivers the wrong answer. Exelis acknowledged this (incident number 294397) and filed a bug report.
>>
>> So this will give a wrong answer:
>> print, a.b['c',[1:-1]]
>
> Here [1:-1] is not a subscript range, it is the colon operator for array creation (introduced in IDL 8.3):
>
> IDL> x=[1:-1]
> IDL> help, x & print, x
> X INT = Array[3]
> 1 0 -1
>
> So [1:-1] is actually an array subscript (with the usual array subscript clipping).
>
>> but this will be ok:
>> print, a.b.c[1:-1]
>
> Here [1:-1] is a subscript range with a negative subscript value.
>
> So the two [1:-1]'s have different meaning.
>
> regards,
> Lajos
Oops, you're right! And I do find the same behaviour, when I actually test Helder's case:
IDL> a = dictionary('b',dictionary('c',findgen(10)))
IDL> a.b.c[[1:-1]]
1.0000000 0.00000000 0.00000000
IDL> a.b.c[1:-1]
1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
7.0000000 8.0000000 9.0000000
IDL> a.b['c',[1:-1]]
1.0000000 0.00000000 0.00000000
IDL> a.b['c',1:-1]
1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
7.0000000 8.0000000 9.0000000
Sorry for the miscommunication!
Cheers,
-Dick
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
|
|
|
Re: buggy dictionary [message #91157 is a reply to message #91155] |
Tue, 09 June 2015 09:15   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
On Tuesday, 9 June 2015 09:10:48 UTC-7, Dick Jackson wrote:
> Oops, you're right! And I do find the same behaviour, when I actually test Helder's case:
>
> IDL> a = dictionary('b',dictionary('c',findgen(10)))
> IDL> a.b.c[[1:-1]]
> 1.0000000 0.00000000 0.00000000
> IDL> a.b.c[1:-1]
> 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
> 7.0000000 8.0000000 9.0000000
> IDL> a.b['c',[1:-1]]
> 1.0000000 0.00000000 0.00000000
> IDL> a.b['c',1:-1]
> 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 6.0000000
> 7.0000000 8.0000000 9.0000000
I should have added:
... running this at a Windows command prompt, right after printing this correct answer, the hard crash happens!
Cheers,
-Dick
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
|
|
|
|