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

Home » Public Forums » archive » get IDL to issue warning or throw error for mismatched arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: get IDL to issue warning or throw error for mismatched arrays [message #93334 is a reply to message #93331] Thu, 16 June 2016 09:43 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
On Thursday, 16 June 2016 07:59:02 UTC-7, Markus Schmassmann wrote:
> is there any way to get IDL to issue a warning or throw an error in for
> mismatched arrays like those below?
>
> indgen(2,2)+indgen(3,3)

Hi Markus,

Here is the behaviour we see, that the result is the size of the "overlapping" of the two arrays:

IDL> help,indgen(2,2)+indgen(3,3)
<Expression> INT = Array[2, 2]


I was hopeful that COMPILE_OPT STRICTARRSUBS would help. Here's what it does, before:

IDL> a=indgen(5)
IDL> a[[3,4,5,6]]
3 4 4 4

... and after:

IDL> compile_opt strictarrsubs
IDL> a[[3,4,5,6]]
% Array used to subscript array contains out of range subscript: A.
% Execution halted at: $MAIN$

So, the STRICTARRSUBS is making a difference in that regard, but...

IDL> help,indgen(2,2)+indgen(3,3)
<Expression> INT = Array[2, 2]

It does not change the behaviour with different-shaped arrays. If you have to test arrays a and b for differing shape, a simple check is:

IF ~Array_Equal(Size(a, /DIMENSIONS), Size(b, /DIMENSIONS)) THEN ...

Hope this helps,
-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 8,2 cannot call ENVI function
Next Topic: Mismatch between video frame dimensions and stream using Coyote graphics

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

Current Time: Wed Oct 08 13:46:57 PDT 2025

Total time taken to generate the page: 0.00416 seconds