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

Home » Public Forums » archive » Re: gurus: example code as main level code ?
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: gurus: example code as main level code ? [message #32762 is a reply to message #32760] Fri, 01 November 2002 09:56 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
R.G. Stockwell wrote:

> Greetings all,
>
> I am going through my monster IDL library, and was wondering what
> people think of the practice of including a main level "example" or
> "Test" code at the end of each function and procedure?
>
> Are there any reasons not to do this?
> I don't see any, but I am probably missing something, i usually am :).
>
> I do this almost always (and in fact, I am planning to make this a rule,
> so that all my functions will have an example if anyone runs the function.
>

Dear Bob,

I am wondering a bit what happens to the example if I do

.compile range
resolve_all
save,file='range.sav',/routines,/compress

It seems only the function is saved in the sav binary.

First I was thinking this could be a problem for the routine
itselfs, but it works fine. I can miss the example by runtime routines.

Normally if we have more complicated routines you need more as one testcase.
Or did you think about having a large main program which tells what it is
testing and what the result should be and is. At the moment I am using the
EXAMPLES: tag in the comments.

By graphic routines this is nearly impossible. There is a saved image better
for comparisons. For the plotenvironment I have already a large image /
testcases which is very useful during beta tests.

Your idea will make it very easy to check math functions and to show
differences if the output is redirected to a file.


regards

Reimar

>
> Cheers,
> bob stockwell
>
>
> As an example of what I mean, here is a tiny (but useful) function:
> You call it as result = range(array), but if you want to see an
> example of the function, just do
> IDL>.run range
>
>
> function range, ts,_extra=_extra
>
> if n_elements(ts) lt 1 then return,-1
> return, [min(ts,_extra=_extra),max(ts,_extra=_extra)]
> end
>
>
> a = findgen(10)+44
>
> print,range(a)
>
> end

--
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: How to get the position of mouse
Next Topic: Re: How to plot many lines simultaneously

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

Current Time: Sun Oct 12 10:31:26 PDT 2025

Total time taken to generate the page: 0.56125 seconds