New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rfft output difference python 2.7.15 / python 3.7.2 #12914
Comments
If you're comparing the numbers based on how they print, it could just be a change in how floats are printed between Python 2 and Python 3, see here (emphasis mine):
If you need the numbers to be identical across Python versions, you should compare their binary representations to see if they are equal, not their string representations. (you might be doing this already and the printing is just for the bug report, but for what it's worth) Then again, I see a different result again on my setup, and I see this both on Python 2 and Python 3:
But I am using the intel math kernel library, perhaps it has a different implementation of sin, or a different fft implementation. You would need to double check that both your Python 2 and 3 installations are using the exact same underlying math libraries. Whilst there are standards defining what basic arithmetic should do for floats, I don't think the same thing exists for ffts or the sine function, such that different implementations may have slightly different floating point rounding errors. |
I'm using the stock python and numpy verison (not using MKL). I did some further tests and it turned out that the difference likely comes from different underlying math libraries. I tested the I think this issue can be closed then as not linked to numpy issue. |
@chrisjbillington AFAIK, Intel indeed uses its own implementation of fft and that is clearly understandable. However, I'm not sure about basic math functions. I get exactly the same answer (icc build as well). @julienprieur there is a very nice answer that explains some differences. I also have checked stock numpy (using a VM) and got the same results. |
Same code using rfft produces slighly different output on python 2 / python 3.
I noticed it because it broke some automatic testing of my internal libraries.
It looks like the latest digit of the real part is being truncated in python 3.
Reproducing code example:
output:
(-0.686231256675454-5.4138146836022445j) in python 3.7.2
(-0.6862312566754544-5.4138146836022445j) in python 2.7.15
Numpy/Python version information:
Numpy version 1.16.0
Python 2.7.15 x64
Python 3.7.2 x64
Windows 10
The text was updated successfully, but these errors were encountered: