[Numpy-discussion] doctest improvements patch (and possible regressions)

Paul Ivanov pivanov314@gmail....
Tue Dec 8 14:57:09 CST 2009


Hi Numpy-devs,

I'm a long time listener, first time caller. I grabbed 1.4.0rc1 and was
happy that all the tests passed. But then I tried:

   >>> import numpy as np
   >>> np.test(doctests=True)
   ...
   Ran 1696 tests in 22.027s

   FAILED (failures=113, errors=24)

I looked at some of the failures, and they looked like trivial typos. So
I said to myself: "Self, wouldn't it be cool if all the doctests worked?"

Well, I didn't quite get there spelunking and snorkeling in the source
code a few evenings during the past week, but I got close.  With the
attached patch (which patches the 1.4.0rc1 tarball), I now get:

   >>> import numpy as np
   >>> np.test(doctests=True)
   ...
   Ran 1696 tests in 20.937s

   FAILED (failures=33, errors=25)


I marked up suspicious differences with XXX, since I don't know if
they're significant. In particular:
 - shortening a defchararray by strip does not change it's dtype to a
shorter one (apparently it used to?)
 - the docstring for seterr says that np.seterr() should reset all
errors to defaults, but clearly doesn't do that
 - there's a regression in recfunctions which may be related to #1299
and may have been fixed
 - recfunctions.find_duplicates ignoremask flag has no effect.

There are a few other things, but they're minor (e.g. I added a note
about how missing values are filled with usemask=False in
recfunctions.merge_arrays).

I think the only code I added was to testing/noseclasses.py. There, if a
test fails, I give a few more chances to pass by normalizing the
endianness of both desired and actual output, as well as default int
size for 32 and 64 bit machines. This is done just using replace() on
the strings.

Everything else is docstring stuff, so I was hoping to sneak this into
1.4.0, since it would make it that much more polished.

Does that sound crazy?

best,
    Paul Ivanov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091208/536c8b48/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: better-doctests.patch.gz
Type: application/x-gzip
Size: 16134 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091208/536c8b48/attachment.gz 


More information about the NumPy-Discussion mailing list