[SciPy-dev] ANN: NumPy/SciPy Documentation Marathon 2008
Johann Cohen-Tanugi
cohen@slac.stanford....
Sun May 18 08:40:32 CDT 2008
ok I will work on the 2) assumption. I do not get it to work with docmod
either.
best,
Johann
Pauli Virtanen wrote:
> Hi,
>
> su, 2008-05-18 kello 14:32 +0200, Johann Cohen-Tanugi kirjoitti:
>
>> thanks. I am looking at fromnumeric.py, and more precisely the examples.
>> When I try doctest.testfile I get a lot of errors and it seems that in
>> every single examples I need to add :
>> >>> from numpy import array
>> >>> from numpy.core.fromnumeric import *
>>
>> So that array is known within the example, as well as the actual
>> function being tested.... I find that a bit strange so I would like to
>> know if there is smthg I do wrong. Here is what I do :
>> [cohen@jarrett core]$ ipython -c "import
>> doctest;doctest.testfile('/home/cohen/data1/sources/python/numpy-svn/numpy/core/fromnumeric.py',module_relative=False)"
>>
>
> I think the problem is that right now very few of the examples can
> actually be ran as doctests, because of the missing import statements.
>
> We still need to decide on a standard way to use imports in the
> examples, and document it more clearly on the wiki. After this is done,
> we need to can out how to run doctests so that the examples pass. And
> after this, we can start testing and fixing the examples.
>
> I think there are three reasonable choices:
>
> 1) Assume 'from numpy import *'
>
> 'import doctest, numpy; doctest.testfile(file_name, globs=numpy.__dict__)'
>
> 2) Assume 'import numpy'
>
> 'import doctest, numpy; doctest.testfile(file_name, globs={"numpy": numpy})'
>
> 3) Assume 'import numpy as np'
>
> 'import doctest, numpy; doctest.testfile(file_name, globs={"np": numpy})'
>
> The default doctest choice of using the __dict__ of the module where the
> test is in might not be reasonable if we want to write examples instead
> of doctests. (And this default choice apparently doesn't work with
> testfile but it works with testmod?)
>
> I think Stéfan suggested 2). I'd say 1) or 2).
>
> Pauli
>
>
> PS. Could you use "Reply all", so that the messages go also to the
> scipy-dev list? I think this discussion has interest also to other
> people.
>
>
>
More information about the Scipy-dev
mailing list