Ask Your Question

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 ... `

 sage: give_me_the_time_taken_to_process(input_data)

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

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.


    sage: give_me_the_time_taken_to_process(input_data)  # random

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

edit flag offensive delete link more


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


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

Seen: 75 times

Last updated: Apr 02