one of the rule for getting code into Sage is 100% doctesting --- what
does it mean exactly?
At least one doctest per function/method? Is there some tool to check
that? I think I remember there was some script for it, but I can't
find it now.
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). Also,
should all tests go to the docstring? I remember asking William about
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).
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?
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.
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.
Also a related question --- where exactly should the tests in the file
"calculus/test_sympy.py" go?
Thanks,
Ondrej
Yes, thanks! It's in local/bin/sage-coverage. Here is an example:
$ sage -coverage devel/sage/sage/calculus/calculus.py
----------------------------------------------------------------------
devel/sage/sage/calculus/calculus.py
SCORE devel/sage/sage/calculus/calculus.py: 83% (15 of 18)
Missing documentation:
* _find_var(name):
* _find_func(name):
* symbolic_expression_from_string(s, syms=None, accept_sequence=False):
----------------------------------------------------------------------
so it only looks if the function has at least one docstring.
Ondrej
It's not a proper parser. It's just a quick "hack" that goes through
the text file and grabs """ (triple quoted strings). It even would
break if you use ''' instead of """. Somebody, maybe you, will make
it better. Precise bug reports would help a lot too, actually.
William
I wrote a similar script for sympy here:
http://github.com/certik/sympy/blob/44725bb2720afdbb2997c4184f8d9919e151af86/bin/coverage_doctest.py
it's still being reviewed, but I copied lots of parts from
sage-coverage.py. Do you think you would please allow me to use my
script under the BSD license? If that is not possible, I'll rewrite
the parts, so that it's not a derived work.
Thanks,
Ondrej