From: David F. <dav...@gm...> - 2011-07-23 12:41:20
|
> The problem is likely not in in fscanf, but rather in the calls to printf. > I suggest re-writing foo_read_values to return the values that it reads, > rather than printf-ing them. Then, check the values that are returned to > python, and see if they are correct. So I've made the test: the returned value is incorrect. I also printf the expected value. The format is different, but it prints correct value. I also compare the read-value with the expected, it confirm the value is wrong. I attach the modified files, and here are the outputs: In pure C: >From C: v0=1.000000, expected=1.000000, n1=1 >From C: v1=2.000000, expected=2.000000, n2=1 >From C: v2=3.000000, expected=3.000000, n3=1 >From C: Read-float has expected value (with a 0.001 tolerance). >From C: Read-float has expected value (with a 0.001 tolerance). >From C: Read-float has expected value (with a 0.001 tolerance). In C/Python, not importing matplotlib: >From C: v0=1.000000, expected=1.000000, n1=1 >From C: v1=2.000000, expected=2.000000, n2=1 >From C: v2=3.000000, expected=3.000000, n3=1 >From C: Read-float has expected value (with a 0.001 tolerance). >From C: Read-float has expected value (with a 0.001 tolerance). >From C: Read-float has expected value (with a 0.001 tolerance). >From Python: returned value is: 3.000000, expected: 3.000000 In C/Python, importing matplotlib: >From C: v0=1,000000, expected=1,000000, n1=1 >From C: v1=-<a random value here>, expected=2,000000, n2=0 >From C: v2=0,000000, expected=3,000000, n3=0 >From C: Read-float has expected value (with a 0.001 tolerance). >From C: Read-float does not have expected value (with a 0.001 tolerance). >From C: Read-float does not have expected value (with a 0.001 tolerance). >From Python: returned value is: 0.000000, expected: 3.000000 Best, David |