[Numpy-discussion] Code samples in docstrings mistaken as doctests
Fernando Perez
fperez.net at gmail.com
Mon Jun 23 14:02:44 EDT 2008
On Mon, Jun 23, 2008 at 1:03 AM, Stéfan van der Walt <stefan at sun.ac.za> wrote:
> 2008/6/23 Alan McIntyre <alan.mcintyre at gmail.com>:
>> Some docstrings have examples of how to use the function that aren't
>> executable code (see numpy.core.defmatrix.bmat for an example) in
>> their current form. Should these examples have the ">>>" removed from
>> them to avoid them being picked up as doctests?
>
> The examples written for the random module warrants the same question.
> First and foremost, the docstrings are there to illustrate to users
> how to use the code; second, to serve as tests.
>
> Example codes should run, but I'm not sure whether they should always
> be valid doctests.
>
> In the `bmat` example, I would remove the '>>>' like you suggested.
There's also the option of marking them so doctest skips them via
#doctest: +SKIP
http://docs.python.org/lib/doctest-options.html
Cheers,
f
More information about the NumPy-Discussion
mailing list