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
First value of array copy changed to zero unexpectedly #16995
Comments
I think this just comes down to what |
Hmmm, interesting, a simpler reproducer:
which switches behaviour based on length. Furthermore, this only happens for strided:
All of this points to SIMD operations casting differently on the C-level. @eric-wieser ah, was typing this, if this is undefined then the difference in vectorized and non-vectorized code is expected I guess. Now the question is whether we should try to do something about it or not. |
@seberg I got two different certain non-zero result among two systems by using your reproducer:
windows server 2008+X86:
CentOS+ARM64:
Since the correct answer is:
I think both vectorized and non-vectorized code have problems. |
How are you determining what the correct answer is? The C standard says
Numpy perhaps doesn't do the best job of saying that it performs arithmetic mostly as if in C, but it doesn't make any guarantee that this will work either. |
I guess the long term goal for these things might be to give a warning/error on these conversions instead, in which case the result is still undefined (and reasonably so). Similar things happen with some division related loops, where we return 0 when float would return NaN (or NaT for timedelta/datetime). |
We now do a somewhat better job here thanks to gh-21437 many/most of these should give a warning. But when the result is well defined by an "integer overflow" occuring such a warning probably will not happen. So I think there is still an "integer overflow" problem so to speak, but not per-se a float to int cast issue anymore. Not sure whether this should be closed, so keeping it open for now. |
Closing, there is an other issue (too lazy to find it now) about whether this should escalate to errors (which would include the option to define it). |
CentOS 8.2.2004, Python 3.8.0, and Pycharm 2020.2
In numpy 1.19.1, the first element for bin_data_block is always zero (not expected)
In numpy 1.18.5 and earlier, the first element is non-zero and correct as it has been with prior versions.
Does not occur on Windows 10 install using same versions. Only CentOS.
The text was updated successfully, but these errors were encountered: