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

Home » Public Forums » archive » Re: V6.0 indexing change
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
Re: V6.0 indexing change [message #36176] Wed, 13 August 2003 23:20
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Wayne Landsman wrote:

> I haven't installed V6.0 yet myself but I have been informed by Mike
> Corcoran of a change that can break some existing code.
>
> Formerly, if one had a structure, say a = {x:indgen(10)} which was
> accessed by a 1 element vector, say i = [3], then the result a.x[i]
> would be a scalar. In V6.0, however, the result is now a 1 element
> vector.
>
> I have to say that the V6.0 method makes more more sense -- subscripting
> with a 1 element vector should return a 1 element vector. But it can
> break existing code because logical tests such as
>
> if a.x[i] EQ 3 then stop
>
> will no longer work. The fix is simple enough ( set i = i[0] first )
> but users might want to fix the code before upgrading to V6.0.

Could this change be interpreted that's trailing dimensions 1 sometimes
later not more removed automaticly.

a=make_Array(4,1)
IDL> help,a
A FLOAT = Array[4]


Reimar
>
> --Wayne Landsman landsman@mpb.gsfc.nasa.gov

--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
Re: V6.0 indexing change [message #36186 is a reply to message #36176] Tue, 12 August 2003 18:51 Go to previous message
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
"Mark Hadfield" <m.hadfield@niwa.co.nz> wrote in message
news:bhc1o5$kl2$3@newsreader.mailgate.org...
>
> Still, Wayne's warning is correct: there may be cases where the new,
> improved structure indexing in 6.0 will break code.
>
Yes, the problem evidently was not with a logical test, but with a case
statement, e.g.

case a.x[i] of
1: print,'hi'
else: print,'bye'
endcase

where a.x[i] is required to be a scalar and not a 1 element vector. --Wayne

P.S. The V6.0 incompatibility occured in the program tbget.pro in the IDL
Astro library.
Re: V6.0 indexing change [message #36188 is a reply to message #36186] Tue, 12 August 2003 17:45 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Andrew Cool wrote:

> Wayne Landsman <landsman@mpb.gsfc.nasa.gov> wrote in message news:<3F39035C.8070409@mpb.gsfc.nasa.gov>...
>
>> I haven't installed V6.0 yet myself but I have been informed by Mike
>> Corcoran of a change that can break some existing code.
>>
>> Formerly, if one had a structure, say a = {x:indgen(10)} which was
>> accessed by a 1 element vector, say i = [3], then the result a.x[i]
>> would be a scalar. In V6.0, however, the result is now a 1 element
>> vector.
>>
>> I have to say that the V6.0 method makes more more sense -- subscripting
>> with a 1 element vector should return a 1 element vector. But it can
>> break existing code because logical tests such as
>>
>> if a.x[i] EQ 3 then stop
>>
>> will no longer work. The fix is simple enough ( set i = i[0] first )
>> but users might want to fix the code before upgrading to V6.0.
>>
>
> You sure about this? Yes, a 1 element vector is now returned, but
> your example
>
> if a.x[i] EQ 3 then stop
>
> works just fine for me under the 6.0 Beta (Win2000), as does
>
> if a.x[i[0]] EQ 3 then stop

And for me under 6.0 final (Win 2000). But then this...

IDL> if [1] eq 1 then print, 'comparison is OK'

...works (ie prints out the message) under IDL 6.0 and 5.6. In other
words an if statement doesn't seem to care if its condition is a scalar
or a 1-element array. News to me!

Still, Wayne's warning is correct: there may be cases where the new,
improved structure indexing in 6.0 will break code.

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)

Gratuitous text to fool the news server. Gratuitous text to fool the
news server. Gratuitous text to fool the news server. Gratuitous text to
fool the news server. Gratuitous text to fool the news server.
Gratuitous text to fool the news server. Gratuitous text to fool the
news server. Gratuitous text to fool the news server. Gratuitous text to
fool the news server. Gratuitous text to fool the news server.
Gratuitous text to fool the news server. Gratuitous text to fool the
news server. Gratuitous text to fool the news server. Gratuitous text to
fool the news server. Gratuitous text to fool the news server.
Gratuitous text to fool the news server. Gratuitous text to fool the
news server. Gratuitous text to fool the news server. Gratuitous text to
fool the news server. Gratuitous text to fool the news server.
Re: V6.0 indexing change [message #36189 is a reply to message #36188] Tue, 12 August 2003 16:04 Go to previous message
andrew.cool is currently offline  andrew.cool
Messages: 47
Registered: July 2003
Member
Wayne Landsman <landsman@mpb.gsfc.nasa.gov> wrote in message news:<3F39035C.8070409@mpb.gsfc.nasa.gov>...
> I haven't installed V6.0 yet myself but I have been informed by Mike
> Corcoran of a change that can break some existing code.
>
> Formerly, if one had a structure, say a = {x:indgen(10)} which was
> accessed by a 1 element vector, say i = [3], then the result a.x[i]
> would be a scalar. In V6.0, however, the result is now a 1 element
> vector.
>
> I have to say that the V6.0 method makes more more sense -- subscripting
> with a 1 element vector should return a 1 element vector. But it can
> break existing code because logical tests such as
>
> if a.x[i] EQ 3 then stop
>
> will no longer work. The fix is simple enough ( set i = i[0] first )
> but users might want to fix the code before upgrading to V6.0.
>
> --Wayne Landsman landsman@mpb.gsfc.nasa.gov


Wayne,

You sure about this? Yes, a 1 element vector is now returned, but
your example

if a.x[i] EQ 3 then stop

works just fine for me under the 6.0 Beta (Win2000), as does

if a.x[i[0]] EQ 3 then stop


Andrew
DSTO, Adelaide, South Australia
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: SAR image formation code??
Next Topic: Unable to get the user value of the top level base after a draw widget expose event

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

Current Time: Wed Oct 08 14:55:40 PDT 2025

Total time taken to generate the page: 0.00429 seconds