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

Home » Public Forums » archive » Non-intuitive result with !Null in Where()
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
Non-intuitive result with !Null in Where() [message #85610] Wed, 21 August 2013 09:42 Go to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
This is not what I expected. If there are no elements, how can "count" be non-zero? I was hoping that Where() would return !Null and "count" would be 0.

IDL> print, n_elements(!Null)
0
IDL> print, where(!Null ne 0, count)
0
IDL> print, count
1
IDL> print, where(!Null ne 0, count, /NULL)
0
IDL> print, count
1
IDL> print, !Null[0]
% Expression must be an array in this context: !NULL.
IDL> print, (!Null)[0]
% Variable is undefined: <UNDEFINED>.


The Where function is telling me I can access !Null at element 0, but I cannot.

IDL> print, !version
{ x86_64 darwin unix Mac OS X 8.0 Jun 17 2010 64 64}
Re: Non-intuitive result with !Null in Where() [message #85611 is a reply to message #85610] Wed, 21 August 2013 09:48 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matthew Argall writes:

> The Where function is telling me I can access !Null at element 0, but I cannot.
>
> IDL> print, !version
> { x86_64 darwin unix Mac OS X 8.0 Jun 17 2010 64 64}

No, the Where function is telling you that !Null is not equal to 0 and
there is 1 element where this is true in the comparison expression.

Seems perfectly reasonable to me.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Non-intuitive result with !Null in Where() [message #85612 is a reply to message #85611] Wed, 21 August 2013 10:52 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> there is 1 element where this is true in the comparison expression.

Doh!
Re: Non-intuitive result with !Null in Where() [message #85616 is a reply to message #85610] Wed, 21 August 2013 16:51 Go to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Wed, 21 Aug 2013 09:42:25 -0700 (PDT), Matthew Argall wrote:

> This is not what I expected. If there are no elements, how can "count" be non-zero? I was hoping that Where() would return !Null and "count" would be 0.
>
> IDL> print, n_elements(!Null)
> 0
> IDL> print, where(!Null ne 0, count)
> 0
> IDL> print, count
> 1
> IDL> print, where(!Null ne 0, count, /NULL)
> 0
> IDL> print, count
> 1
> IDL> print, !Null[0]
> % Expression must be an array in this context: !NULL.
> IDL> print, (!Null)[0]
> % Variable is undefined: <UNDEFINED>.
>
>
> The Where function is telling me I can access !Null at element 0, but I cannot.
>
This is not true. In your words, the Where function is telling you,
that the expression !null ne 0 has one element, which is not equal 0.
And the position of this element is 0.

IDL> expr=!null ne 0
IDL> help,expr[0]
<Expression> BYTE = 1

Heinz
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: stacking the images according to julian date
Next Topic: Re: spawn not working

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

Current Time: Wed Oct 08 13:48:35 PDT 2025

Total time taken to generate the page: 0.00679 seconds