On 1/27/07, Charles R Harris <[EMAIL PROTECTED]> wrote:

Hmmm, and your problem machine is running smp linux. As is mine; fedora uses
smp even on single processor machines these days. I think we could use more
data here comparing

OSX
Linux (single, smp)
Window

OK, this is weird.  I modified the repeat code a little to ease
collecting of results, and all of a sudden the differences went away.
If you look at the attached code, here's what happens for me:

a) If I have line 77 like this (commented out):

   #print '-'*75

I get:

[...]
94 z different 8.47032947254e-22
95 z different 8.47032947254e-22
96 z different 8.47032947254e-22
98 z different 8.47032947254e-22
99 z different 8.47032947254e-22

Numpy version: 1.0.2.dev3521

test1:  0  differences
test2:  75  differences
test3:  0  differences



b) If I remove the comment char from that line, I get:

tlon[~/Desktop]> python repeat.py

---------------------------------------------------------------------------
Numpy version: 1.0.2.dev3521

test1:  0  differences
test2:  0  differences
test3:  0  differences


That's it.  One comment char removed, and something that's done
/after/ the tests are actually executed.

That kind of 'I add a printf() call and the bug disappears' is
unpleasantly reminiscent of lurking pointer errors in C code...

Cheers,

f
import numpy as N
import numpy.matlib as M
    
def load():

    # x data
    x = M.zeros((3,3))
    x[0,0] = 0.00301404794991108
    x[0,1] = 0.00264742266711118
    x[0,2] = -0.00112705028731085
    x[1,0] = 0.0228605377994491
    x[1,1] = 0.00337153112741583
    x[1,2] = -0.00823674912992519
    x[2,0] = 0.00447839875836716
    x[2,1] = 0.00274880280576514
    x[2,2] = -0.00161133933606597
         
    # y data
    y = M.zeros((3,1))
    y[0,0] = 0.000885398
    y[1,0] = 0.00667193
    y[2,0] = 0.000324727
    
    return x, y
    
def calc(x, y): 
    return x * (x.T * y)                             

def test1(nsim=100):
    x, y = load() 
    z0 = calc(x, y)
    ndiff = 0
    for i in xrange(nsim):
        z = calc(x, y)
        if (z != z0).any():
            ndiff += 1
            print i, 'z different', abs(z - z0).max()       
    return ndiff         
            
def test2(nsim=100):
    x0, y0 = load() 
    z0 = calc(x0, y0)
    ndiff = 0
    for i in xrange(nsim):
        x, y = load() 
        z = calc(x, y)
        if (x != x0).any():
            print i, 'x different', abs(x - x0).max()
        if (y != y0).any():
            print i, 'y different', abs(y - y0).max()
        if (z != z0).any():
            print i, 'z different', abs(z - z0).max()
            ndiff += 1  
    return ndiff  
    
def test3(nsim=100):
    x0, y0 = load() 
    z0 = calc(100*x0, y0) / (100 * 100)
    ndiff = 0
    for i in xrange(nsim):
        x, y = load() 
        z = calc(100*x, y) / (100 * 100)
        if (x != x0).any():
            print i, 'x different', abs(x - x0).max()
        if (y != y0).any():
            print i, 'y different', abs(y - y0).max()
        if (z != z0).any():
            print i, 'z different', abs(z - z0).max()
            ndiff += 1      
    return ndiff         
    
def all():
    n1 = test1()
    n2 = test2() 
    n3 = test3()
    print
    print '-'*75
    print 'Numpy version:',N.__version__
    print
    print 'test1: ', n1, ' differences'
    print 'test2: ', n2, ' differences'                            
    print 'test3: ', n3, ' differences'

    
all()
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to