comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Dictionary error does not generate error
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Dictionary error does not generate error [message #89537] Fri, 24 October 2014 04:12 Go to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi,
the help the dictionary() function states at the end (from http://www.exelisvis.com/docs/DICTIONARY.html):

;*** Start citation ***
Difference between Dictionary and IDL Structures
Unlike IDL structures, when indexing into an array within a dictionary, you can not use the "dot" notation to retrieve the key's value and then index into the "dot" value. This is because the DICTIONARY is implemented as a "container" of data pointers instead of a structure that is laid out directly into memory. For 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
;*** end citation ***

If I insert the dictionary part in IDL 8.4, I get:

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

To me, that works just as the structure (correctly, should I say?).

Has this been repaired in 8.4 as compared to 8.3 or previous versions? Or are there other problems connected with indexing of dictionaries?

It's quite important I get this straight, because I'm using dictionaries quite intensively.

Thanks,
Helder
Re: Dictionary error does not generate error [message #89538 is a reply to message #89537] Fri, 24 October 2014 04:53 Go to previous messageGo to next message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
IDL 8.3:

IDL> dict = DICTIONARY('data', FINDGEN(10))
IDL> PRINT, dict.data[2:5]
% Subscripts are not allowed with object properties.
% Execution halted at: $MAIN$
IDL> PRINT, (dict.data)[2:5]
2.00000 3.00000 4.00000 5.00000

IF the syntax: dict.data[2:5] now works in 8.4, this would be so great!
The use of () makes nested dictionaries really cumbersome to use
Re: Dictionary error does not generate error [message #89539 is a reply to message #89538] Fri, 24 October 2014 05:02 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Friday, October 24, 2014 1:53:31 PM UTC+2, Fabien wrote:
> IDL 8.3:
>
> IDL> dict = DICTIONARY('data', FINDGEN(10))
> IDL> PRINT, dict.data[2:5]
> % Subscripts are not allowed with object properties.
> % Execution halted at: $MAIN$
> IDL> PRINT, (dict.data)[2:5]
> 2.00000 3.00000 4.00000 5.00000
>
> IF the syntax: dict.data[2:5] now works in 8.4, this would be so great!
> The use of () makes nested dictionaries really cumbersome to use

Well, it's looking good in 8.4, so as you said... one can get rid of quite some (). Good.

Cheers,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: windows blue screen
Next Topic: Re: IDL 8.2+ Segmentation Fault / Abort on OSX with Dual-Thunderbolt Displays

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:14:54 PDT 2025

Total time taken to generate the page: 0.00600 seconds