On Mon, Jun 22, 2009 at 1:41 AM, Ondrej Certik<ond...@certik.cz> wrote:
>
> Hi,
>
> one of the rule for getting code into Sage is 100% doctesting --- what
> does it mean exactly?
> At least one doctest per function/method?

Yes.

>  Is there some tool to check
> that?

Yes.

>  I think I remember there was some script for it, but I can't
> find it now.

sage -coverage file.py

I wrote the first version of that script during a docday so I could
figure out what to doctest.  It subsequently got traction.

> However, at least to me, just one doctest per function is not enough,
> I like to have the code 100% tested, which is a completely different
> thing (but so far I didn't have much luck with automatic testing tools
> to test it, like figleaf or coverage, I'll try to look into it again,
> but I was curious if any of you have more experience with this).

That is a worthy goal.  But it should come after getting 100% of
functions tested *at all*, which is also a worthy goal.  Note that
when people referee patches and look at the doctests, they of course
often complain if the tests don't test "everything".  For example,
when refereeing if I look at a function foo that takes as input
parameters bar and xyz, and the doctests don't have "bar" and "xyz" in
them, I immediately complain (maybe the script should too).

> Also,
> should all tests go to the docstring? I remember asking William about

I think they should for Sage, yes.  For other projects, e.g., twisted,
this would make no sense at all.

> it on IRC some time ago and he said it should (e.g. the TESTS section
> is not shown in the docstring in ipython with sage patches). I can't
> find the TESTS section here:
>
> http://sagemath.org/doc/developer/conventions.html
>
> but I thought I saw it somewhere (correct me if I am wrong).

Yes, there is a TESTS section.  We don't treat it differently yet, but
*plan* to.
The TESTS section is just part of the docstring.

> In sympy, for example for the Order() class (holding the order in the
> series expansion, e.g. the "O" term) has about 100 lines of tests. So
> in Sage you would just put all of them into the docstring?

There are also lots of tests that aren't in doctrings.  There's whole
modules that create randomized tests.  People run there for fun every
so often.  Also -- and this is important -- there are doctests in
docstrings that call the randomized tests just to make sure they still
work.

> I however like that each function has at least one doctest showing the
> actual usage of the function, so once I write (or borrow from Sage)
> some script to automatically check that, I am going to impose that for
> all new code going to sympy (note again, that this is about the
> examples, the actual tests were always required). Because this shows
> very nice in the sphinx documentation.

+1  Thanks!

> I am asking here, because you have the experience with holding all
> tests in the docstring itself, so I am curious about your opinion of
> it.

I think it is an excellent first step.

> Also a related question --- where exactly should the tests in the file
> "calculus/test_sympy.py" go?
>
> Thanks,
> Ondrej
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to