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

Home » Public Forums » archive » Unexpected array subscript truncation
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
Unexpected array subscript truncation [message #68881] Mon, 30 November 2009 13:03
M. Katz is currently offline  M. Katz
Messages: 69
Registered: May 2005
Member
Here's an interesting little array trick I discovered by accident. It
doesn't give an error message where I would expect one! Try this:

* As a warm-up enter this and see that IDL does complain.

a = intarr(3,3)
a[0,5] = 1

* Now try to set it as follows, with an array of y-index values.

a[0,[0,5]] = 1
print, a
1 0 0
0 0 0
1 0 0

No complaint! In fact, IDL quietly truncated the 5 down to its highest
allowed value, which is 2.

It also works like this:

a[*,[0,9]] = 3

is equivalent to

a[*,[0,2]] = 3

The same truncation happens with x indices as well.

I suppose there could be some cases where this would not be the
desired behavior. Any thoughts? Am I missing something?

-M.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: costum stretch an image
Next Topic: How to store compressed data ?

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

Current Time: Wed Oct 08 19:35:19 PDT 2025

Total time taken to generate the page: 0.00566 seconds