[Numpy-discussion] NumpyTest problem

Christopher Burns cburns at berkeley.edu
Wed Jun 4 00:39:22 EDT 2008


Pierre,

I believe if you rename your TimingTests they'll work.  Nose looks for
functions starting with "test", and runs those.  So your 'utility' functions
like testta, testtb... should not begin with "test", but the function
calling them, timingTest, should.  Probably want to use more meaningful
names than my hack though.  :)

def test_timingTest():
    for f in [testf, testinplace]:
        for n in [1000,10000,50000]:
            t = func_ta(n, f)
            t1 = testtb(n, f)
            t2 = testtc(n, f)
            print f.test_name
            print """\
n = %7d
numpy time (ms) %6.1f
MA maskless ratio %6.1f
MA masked ratio %6.1f
""" % (n, t*1000.0, t1/t, t2/t)

def func_ta(n, f):
    x=numpy.arange(n) + 1.0
    tn0 = time.time()
    z = f(x)
    return time.time() - tn0

Then to run only test_timingTest:

cburns at tests 21:30:19 $ pwd
/Users/cburns/src/numpy-trunk/numpy/ma/tests

cburns at tests 21:33:13 $ nosetests -sv test_old_ma:test_timingTest
test_old_ma.test_timingTest ... Simple arithmetic
n =    1000
numpy time (ms)    1.9
MA maskless ratio   14.9
MA masked ratio   18.4

[snip]

----------------------------------------------------------------------
Ran 1 test in 2.912s

OK


On Mon, Jun 2, 2008 at 8:04 PM, Pierre GM <pgmdevlist at gmail.com> wrote:

>
> * Running nosetests on numpy/ma fails (I can't import numpy from the source
> directory), but works partially on numpy/ma/tests: the test_old_ma tests
> fail
> for asking some arguments when 0 is provided: for example:
> ================================================
> ERROR: test_old_ma.testta
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib64/python2.4/site-packages/nose/case.py", line 203, in
> runTest
>    self.test(*self.arg)
> TypeError: testta() takes exactly 2 arguments (0 given)
>
>
-- 
Christopher Burns
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080603/83c8b722/attachment.html>


More information about the NumPy-Discussion mailing list