Re: Most Common IDL Programming Errors [message #59803 is a reply to message #59761] |
Thu, 10 April 2008 02:29   |
Erik[1]
Messages: 23 Registered: December 2006
|
Junior Member |
|
|
On 10 apr, 04:18, Tom McGlynn <t...@milkyway.gsfc.nasa.gov> wrote:
> One problem that I used to make all the time was to assume that WHERE
> returned a match, e.g.,
>
> w = where(x gt 0)
> x[w] = alog10(x[w])
>
> neglecting the case where the x are all negative. My programs would
> always work when I tested them, and then I'd find they failed when I
> tried them in the real world. The need to check finally got beaten
> into me.
>
> Another is fogetting the inherently parallel nature of array
> operations, e.g., something like expecting
>
> x=[0,1,1,2,2,2]
> y=indgen(3)
>
> y[x] = y[x]+1
>
> to give something other than 1,1,1.
>
> Regards,
> Tom McGlynn
Quote:
- Coding up your own function when there's a perfectly useful inbuilt
command that'll do what you want, and can even do it without three
nested FOR loops ;-)
Lol! So true this one!
|
|
|