Ask Your Question
2

Dynamic documentation, how to use EXAMPLE:: tag?

asked 2024-04-02 16:33:19 +0200

Dear all, I'm writing the documentation of a package. A function described answers the time taken by the computation (and other things). Problem: this time varies ... `

 EXAMPLE::
 sage: give_me_the_time_taken_to_process(input_data)
 0.03s

Since Sagemath runs doctest, it tests this example and issues a warning every time the time taken is different -- Do you have a good solution for me? Many thanks in advance! Olivier

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-04-02 16:50:52 +0200

slelievre gravatar image

updated 2024-04-02 17:49:38 +0200

One option is to add a "random" tag.

Then, when testing, the value of the output will be ignored.

Running the test will only test whether an exception is raised.

EXAMPLES::

    sage: give_me_the_time_taken_to_process(input_data)  # random
    0.03s

See the developer manual, chapter "Coding basics", section "Special markup to influence doctests":

edit flag offensive delete link more

Comments

Great, thanks! Olivier

Olivier R. gravatar imageOlivier R. ( 2024-04-02 17:03:06 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-04-02 16:33:19 +0200

Seen: 75 times

Last updated: Apr 02