[Numpy-discussion] Different results from repeated calculation, part 2

Bruce Southey bsouthey@gmail....
Thu Aug 14 13:29:29 CDT 2008


Keith Goodman wrote:
> I get slightly different results when I repeat a calculation.
>
> I've seen this problem before (it went away but has returned):
>
> http://projects.scipy.org/pipermail/numpy-discussion/2007-January/025724.html
>
> A unit test is attached. It contains three tests:
>
> In test1, I construct matrices x and y and then repeatedly calculate z
> = calc(x,y). The result z is the same every time. So this test passes.
>
> In test2, I construct matrices x and y each time before calculating z
> = calc(x,y). Sometimes z is slightly different. But the x's test to be
> equal and so do the y's. This test fails (on Debian Lenny, Core 2 Duo,
> with libatlas3gf-sse2 but not with libatlas3gf-sse).
>
> test3 is the same as test2 but I calculate z like this: z =
> calc(100*x,y) / (100 * 100). This test passes.
>
> I get:
>
> ======================================================================
> FAIL: repeatability #2
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/[snip]/test/repeat_test.py", line 73, in test_repeat_2
>     self.assert_(result, msg)
> AssertionError: Max difference = 2.04946e-16
>
> ----------------------------------------------------------------------
>
> Should a unit test like this be added to numpy?
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
Hi,
In the function 'test_repeat_2' you are redefining variables 'x and y' 
that were first defined using the setup function. (Also, you are not 
using the __init__ function.) I vaguely recall there are some quirks to 
Python classes with this, so does the problem go away with if you use 
'a,b' instead of 'x, y'? (I suspect the answer is yes given test_repeat_3).

Note that you should also test that 'x' and 'y' are same here as well 
(but these have been redefined...).

Otherwise, can you please provide your OS (version), computer processor, 
Python version, numpy version, version of atlas (or similar) and 
compiler used?

 I went back and reread the thread but I could not see this information.

Bruce





More information about the Numpy-discussion mailing list