[Numpy-discussion] Proposal for matrix_rank function in numpy

josef.pktd@gmai... josef.pktd@gmai...
Fri Dec 18 21:47:26 CST 2009


On Fri, Dec 18, 2009 at 10:21 PM, Fernando Perez <fperez.net@gmail.com> wrote:
> On Wed, Dec 16, 2009 at 10:56 AM, Skipper Seabold <jsseabold@gmail.com> wrote:
>> Presumably the doctests should be turned into
>> actual tests (noting Robert's comment) to make it more likely that it
>> gets in
>
> Just curious: is there a policy against pure doctests in numpy? I've
> always found that doctests and 'real tests' serve complementary
> purposes and are both useful:
>
> - small, clear tests that make for *illustrative* examples for the end
> user should be left in the docstring, and picked up by the test suite
> as normal doctests.
>
> - tests with a lot more logic that get cumbersome to write as doctests
> can go into 'normal' tests into the test suite.
>
> - There's also a valid third category: for cases where it's convenient
> to write the test interactively but one doesn't want the example in
> the main docstring, putting a function in the test suite that simply
> has the doctest as a docstring works (it may require a little
> decorator, I don't recall).
>
> I'm just wondering if there's a policy of requiring that all tests
> become non-doctests...

doctests have cross platform rendering/printing/formatting problems

1e-01 versus 1e-001  there was a test failure recently with, I think, cheby
also nans render differently, even scalar nan versus nans in arrays.

I don't know about differences across versions of python, numpy, ...
but doctests are very fragile for numbers because they also test the formatting.

Also, the precision is not as easy to control on a test-by-test basis
than with assert_almost_equal or similar and easier to adjust when the
implementation changes (e.g. in stats).

I think, doctests are faster to write but more work to maintain.

But I don't know of any "official" policy,
http://projects.scipy.org/numpy/wiki/TestingGuidelines#doctests
explains how to do them but no recommendation whether to use them or not.

Josef


>
> Cheers,
>
> f
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list