[Numpy-discussion] Code samples in docstrings mistaken as doctests

Alan McIntyre alan.mcintyre@gmail....
Wed Jun 25 12:19:05 CDT 2008


On Mon, Jun 23, 2008 at 3:03 PM, Alan McIntyre <alan.mcintyre@gmail.com> wrote:
> On Mon, Jun 23, 2008 at 2:37 PM, Pauli Virtanen <pav@iki.fi> wrote:
>> Can you make the convention chosen for the examples (currently only in
>> the doc wiki, not yet in SVN) to work: assuming "import numpy as np" in
>> examples?
>>
>> This would remove the need for those "from numpy import *" lines in the
>> examples that I see were added in r5311.
>
> Sure, I'll look at that.  It seems like every possible option for
> importing stuff from numpy is used in doctests (sometimes even in the
> same module), so having them standardized with that implicit import is
> much better.

It turns out it's possible to give all the doctests an implicit
"import numpy as np" (and probably any other arbitrary tweaks to their
execution context, if need be).  Once I can include some of the other
doctest tweaks discussed in this thread, and it's checked in, I'll go
back and remove all those "import numpy" statements I inserted into
the docstrings.

Alan


More information about the Numpy-discussion mailing list