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

2008-06-25 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 2:37 PM, Pauli Virtanen <[EMAIL PROTECTED]> 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? Are there any other implicit imports that we will need? How abo

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

2008-06-25 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 3:03 PM, Alan McIntyre <[EMAIL PROTECTED]> wrote: > On Mon, Jun 23, 2008 at 2:37 PM, Pauli Virtanen <[EMAIL PROTECTED]> 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

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

2008-06-23 Thread Robert Kern
On Mon, Jun 23, 2008 at 22:53, Anne Archibald <[EMAIL PROTECTED]> wrote: > 2008/6/23 Michael Abshoff <[EMAIL PROTECTED]>: >> Correct, but so far Carl has hooked into six out of the many random >> number generators in the various components of Sage. This way we can set >> a global seed and also mor

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

2008-06-23 Thread Anne Archibald
2008/6/23 Michael Abshoff <[EMAIL PROTECTED]>: > Charles R Harris wrote: >> >> >> On Mon, Jun 23, 2008 at 5:58 PM, Michael Abshoff >> <[EMAIL PROTECTED] > >> wrote: >> >> Stéfan van der Walt wrote: >> > 2008/6/24 Stéfan van der Walt <[EMAIL PROTECTED] >>

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

2008-06-23 Thread Anne Archibald
2008/6/23 Stéfan van der Walt <[EMAIL PROTECTED]>: > 2008/6/24 Stéfan van der Walt <[EMAIL PROTECTED]>: >> It should be fairly easy to execute the example code, just to make >> sure it runs. We can always work out a scheme to test its validity >> later. > > Mike Hansen just explained to me that th

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

2008-06-23 Thread Michael Abshoff
Charles R Harris wrote: > > > On Mon, Jun 23, 2008 at 5:58 PM, Michael Abshoff > <[EMAIL PROTECTED] > > wrote: > > Stéfan van der Walt wrote: > > 2008/6/24 Stéfan van der Walt <[EMAIL PROTECTED] > >: > >> It should be fairly

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

2008-06-23 Thread Charles R Harris
On Mon, Jun 23, 2008 at 5:58 PM, Michael Abshoff < [EMAIL PROTECTED]> wrote: > Stéfan van der Walt wrote: > > 2008/6/24 Stéfan van der Walt <[EMAIL PROTECTED]>: > >> It should be fairly easy to execute the example code, just to make > >> sure it runs. We can always work out a scheme to test its v

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

2008-06-23 Thread Fernando Perez
On Mon, Jun 23, 2008 at 5:26 PM, Michael Abshoff <[EMAIL PROTECTED]> wrote: > I am not the author, so I need to find out who wrote the code, but I am > sure it can be made BSD. We are also working on "doctest+timeit" to hunt > for performance regressions, but that one is not ready for prime time y

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

2008-06-23 Thread Michael Abshoff
Fernando Perez wrote: > On Mon, Jun 23, 2008 at 4:58 PM, Michael Abshoff > <[EMAIL PROTECTED]> wrote: Hi Fernando, >>> a) Random variables >> we have some small extensions to the doctesting framework that allow us >> to mark doctests as "#random" so that the result it not checked. Carl >> Witty w

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

2008-06-23 Thread Fernando Perez
On Mon, Jun 23, 2008 at 4:58 PM, Michael Abshoff <[EMAIL PROTECTED]> wrote: >> a) Random variables > > we have some small extensions to the doctesting framework that allow us > to mark doctests as "#random" so that the result it not checked. Carl > Witty wrote some code that makes the random numbe

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

2008-06-23 Thread Michael Abshoff
Stéfan van der Walt wrote: > 2008/6/24 Stéfan van der Walt <[EMAIL PROTECTED]>: >> It should be fairly easy to execute the example code, just to make >> sure it runs. We can always work out a scheme to test its validity >> later. Hi, > Mike Hansen just explained to me that the Sage doctest syste

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

2008-06-23 Thread Stéfan van der Walt
2008/6/24 Stéfan van der Walt <[EMAIL PROTECTED]>: > It should be fairly easy to execute the example code, just to make > sure it runs. We can always work out a scheme to test its validity > later. Mike Hansen just explained to me that the Sage doctest system sets the random seed before executing

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

2008-06-23 Thread Stéfan van der Walt
2008/6/23 Michael McNeil Forbes <[EMAIL PROTECTED]>: > One can usually do #3 -> #1 or #2 by just leave bare assignments > without printing a result (the user can always execute them and look > at the result if they want). > > >>> r = np.random.rand(3,2,4) > > which is cleaner than adding any flags

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

2008-06-23 Thread Robert Kern
On Mon, Jun 23, 2008 at 16:51, Michael McNeil Forbes <[EMAIL PROTECTED]> wrote: >> On Mon, Jun 23, 2008 at 4:51 PM, Robert Kern >> <[EMAIL PROTECTED]> wrote: >>> random_array = np.random.rand(3,4) >>> random_array.shape (3,4) >>> random_array.max() < 1 True >>> random_arra

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

2008-06-23 Thread Michael McNeil Forbes
> On Mon, Jun 23, 2008 at 4:51 PM, Robert Kern > <[EMAIL PROTECTED]> wrote: >> random_array = np.random.rand(3,4) >> random_array.shape >>> (3,4) >> random_array.max() < 1 >>> True >> random_array.min() > 0 >>> True >> >> Yes, this makes it doctestable, but you've destroyed the ex

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

2008-06-23 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 4:51 PM, Robert Kern <[EMAIL PROTECTED]> wrote: >> I agree that this can be awkward sometimes, and should certainly not >> be policy, but one can usually get around this. Instead of printing >> the result, you can use it, or demonstrate porperties: >> >> >>> random_array =

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

2008-06-23 Thread Robert Kern
On Mon, Jun 23, 2008 at 15:44, Michael McNeil Forbes <[EMAIL PROTECTED]> wrote: > On 23 Jun 2008, at 1:28 PM, Anne Archibald wrote: > >> 2008/6/23 Michael McNeil Forbes <[EMAIL PROTECTED]>: >>> Thus, one can argue that all examples should also be doctests. This >>> generally makes things a little

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

2008-06-23 Thread Michael McNeil Forbes
On 23 Jun 2008, at 1:28 PM, Anne Archibald wrote: > 2008/6/23 Michael McNeil Forbes <[EMAIL PROTECTED]>: >> Thus, one can argue that all examples should also be doctests. This >> generally makes things a little more ugly, but much less ambiguous. > > This is a bit awkward. How do you give an exam

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

2008-06-23 Thread Anne Archibald
2008/6/23 Michael McNeil Forbes <[EMAIL PROTECTED]>: >> On 23 Jun 2008, at 12:37 PM, Alan McIntyre wrote: >>> Ugh. That just seems like a lot of unreadable ugliness to me. If >>> this comment magic is the only way to make that stuff execute >>> properly >>> under doctest, I think I'd rather just

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

2008-06-23 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 4:07 PM, Pauli Virtanen <[EMAIL PROTECTED]> wrote: > Another idea (in addition to whitelisting): how easy would it be to > subclass doctest.DocTestParser so that it would eg. automatically +IGNORE > any doctest lines containing ">>> plt."? I'll play around with that and see

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

2008-06-23 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 3:57 PM, Pauli Virtanen <[EMAIL PROTECTED]> wrote: > "Schematic" code (such as that currently in numpy.bmat) that doesn't run > probably shouldn't be written with >>>, and for it the ReST block quote > syntax is also looks OK. > > But I'm personally not in favor of a distinc

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

2008-06-23 Thread Pauli Virtanen
Mon, 23 Jun 2008 15:53:55 -0400, Anne Archibald wrote: > 2008/6/23 Alan McIntyre <[EMAIL PROTECTED]>: >> On Mon, Jun 23, 2008 at 3:21 PM, Stéfan van der Walt <[EMAIL PROTECTED]> >> wrote: >>> Another alternative is to replace +SKIP with something like +IGNORE. >>> That way, the statement is still

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

2008-06-23 Thread Michael McNeil Forbes
> On 23 Jun 2008, at 12:37 PM, Alan McIntyre wrote: >> Ugh. That just seems like a lot of unreadable ugliness to me. If >> this comment magic is the only way to make that stuff execute >> properly >> under doctest, I think I'd rather just skip it in favor of clean, >> uncluttered, non-doctestab

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

2008-06-23 Thread Pauli Virtanen
Mon, 23 Jun 2008 10:03:28 +0200, Stéfan van der Walt wrote: > 2008/6/23 Alan McIntyre <[EMAIL PROTECTED]>: >> 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

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

2008-06-23 Thread Anne Archibald
2008/6/23 Alan McIntyre <[EMAIL PROTECTED]>: > On Mon, Jun 23, 2008 at 3:21 PM, Stéfan van der Walt <[EMAIL PROTECTED]> > wrote: >> Another alternative is to replace +SKIP with something like +IGNORE. >> That way, the statement is still executed, we just don't care about >> its outcome. If we ski

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

2008-06-23 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 3:21 PM, Stéfan van der Walt <[EMAIL PROTECTED]> wrote: > Another alternative is to replace +SKIP with something like +IGNORE. > That way, the statement is still executed, we just don't care about > its outcome. If we skip the line entirely, it often affects the rest > of t

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

2008-06-23 Thread Stéfan van der Walt
2008/6/23 Fernando Perez <[EMAIL PROTECTED]>: > On Mon, Jun 23, 2008 at 11:17 AM, Alan McIntyre <[EMAIL PROTECTED]> wrote: >> On Mon, Jun 23, 2008 at 2:02 PM, Fernando Perez <[EMAIL PROTECTED]> wrote: >>> There's also the option of marking them so doctest skips them via >>> >>> #doctest: +SKIP >>>

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

2008-06-23 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 2:37 PM, Pauli Virtanen <[EMAIL PROTECTED]> 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 *" li

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

2008-06-23 Thread Fernando Perez
On Mon, Jun 23, 2008 at 11:17 AM, Alan McIntyre <[EMAIL PROTECTED]> wrote: > On Mon, Jun 23, 2008 at 2:02 PM, Fernando Perez <[EMAIL PROTECTED]> wrote: >> There's also the option of marking them so doctest skips them via >> >> #doctest: +SKIP >> >> http://docs.python.org/lib/doctest-options.html >

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

2008-06-23 Thread Pauli Virtanen
Mon, 23 Jun 2008 14:17:09 -0400, Alan McIntyre wrote: > On Mon, Jun 23, 2008 at 2:02 PM, Fernando Perez <[EMAIL PROTECTED]> > wrote: >> There's also the option of marking them so doctest skips them via >> >> #doctest: +SKIP >> >> http://docs.python.org/lib/doctest-options.html > > For short examp

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

2008-06-23 Thread Alan McIntyre
On Mon, Jun 23, 2008 at 2:02 PM, Fernando Perez <[EMAIL PROTECTED]> wrote: > There's also the option of marking them so doctest skips them via > > #doctest: +SKIP > > http://docs.python.org/lib/doctest-options.html For short examples, that seems like a good option, but it seems like you have to ha

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

2008-06-23 Thread Fernando Perez
On Mon, Jun 23, 2008 at 1:03 AM, Stéfan van der Walt <[EMAIL PROTECTED]> wrote: > 2008/6/23 Alan McIntyre <[EMAIL PROTECTED]>: >> 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

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

2008-06-23 Thread Stéfan van der Walt
2008/6/23 Alan McIntyre <[EMAIL PROTECTED]>: > 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 do

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

2008-06-23 Thread Alan McIntyre
Hi all, 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? Thanks, Alan __