FCS-analysis / multipletau

python multiple-tau correlation algorithm
https://multipletau.readthedocs.io
BSD 3-Clause "New" or "Revised" License
19 stars 9 forks source link

tests fail on i386 #11

Closed mestia closed 7 years ago

mestia commented 7 years ago

Hi, in Debian python-multipletau fails on i386 Debian bug 860624 Could you please have a look ?

paulmueller commented 7 years ago

Aha, it seems that np.float is the Python built-in float, which should be, but not always seems to be (depending on the C compiler used) a 64bit float. My guess is that the Python float in the i386 build machine is actually 32bit. Could you please try https://github.com/FCS-analysis/multipletau/commit/4a74137f9d9090571893388937b31188d9973132?

mestia commented 7 years ago

the commit fixes the AttributeError but tests still fail with AssertionError. You still can see it here 860624

=================================== FAILURES =================================== ____ test_ac_simple ____

def test_ac_simple():                                      
    myframe = sys._getframe()                              
    myname = myframe.f_code.co_name                        
    print("running ", myname)                              

    arrs = get_sample_arrays()                             

    res = []                                               
    for a in arrs:                                         
        r = multipletau.autocorrelate(a=a,                 
                                      m=16,                
                                      deltat=1,            
                                      normalize=False,     
                                      copy=True,           
                                      dtype=np.float_)     
        res.append(r)                                      

    res = np.concatenate(res)                              
    #np.save(os.path.dirname(__file__)+"/data/"+os.path.basename(__file__)+"_"+myname+".npy", res)
    ref = get_reference_data(myname, __file__)             
  assert np.all(res==ref)                                

E assert False
E + where False = <function all at 0xb612d79c>(array([[ 0.0...4640390e+21]]) == array([[ 0.00...4640390e+21]]) E + where <function all at 0xb612d79c> = np.all
E Use -v to get the full diff)

tests/test_autocorrelate.py:65: AssertionError

Any idea how to fix that ?

paulmueller commented 7 years ago

The link you sent (860624) is the old build. I could allow these tests to fail on i386. I thought it had to do with floating point precision, but the problem seems to lie somewhere else. Python should always use np.float64 for np.float_. Are the tests run on a standard debian image that I could run in a VM and play around with?

mestia commented 7 years ago

Build fails on a standart Debian Stretch - current testing. If only tests are broken and it is complicated to fix them then I guess I can exclude the tests on i386 and propose that as the temporary workaround.

paulmueller commented 7 years ago

Ok, I will have a look an let you know when I have a clear picture of the problem. I could also create rules for i386 Python, so you probably won't have to implement any workaround.

paulmueller commented 7 years ago

It now works for me. I will release version 0.1.7, if it works for you.

The problem was that floating point operations are not always implemented the same way, e.g.:

mestia commented 7 years ago

Thanks, yes, please release it. What are the major changes, the tests ?

paulmueller commented 7 years ago

Yes, the major changes are the tests. The minor change is that multipletau now always uses numpy dtypes by default, which I feel better about, but which should not affect any use case.

mestia commented 7 years ago

Thanks for fixing the problem.