问题
I'm encountering a strange accuracy difference between ipython and the ipython notebook when using a fortran module compiled with f2py.
My fortran module is:
subroutine tt(string,fmt,n_num,out)
implicit none
INTEGER,INTENT(IN)::n_num
CHARACTER(LEN=*),INTENT(IN)::string
CHARACTER(LEN=*),INTENT(IN)::fmt
DOUBLE PRECISION,INTENT(OUT)::out(n_num)
read(string,fmt) out
end subroutine tt
Compiling with: f2py -c -m andre tt.f90
In ipython i get:
In [1]: import numpy as np
In [2]: import andre
In [3]: out = np.array(andre.tt(' 0.34 4.56 5.67','(3f5.2)',3),dtype=np.float)
In [4]: print out
[ 0.34 4.56 5.67]
which is the desired output. However, in the ipython notebook, using the same code, I get:
print out
print out+0.0001
[ 0. 4. 5.]
[ 1.00000000e-04 4.00010000e+00 5.00010000e+00]
What am I doing wrong?
来源:https://stackoverflow.com/questions/15834327/strange-accuracy-difference-between-ipython-and-ipython-notebook-then-using-fort