numpy unexpectedly raises zero division error if array is long enough
See original GitHub issueSteps to reproduce:
with np.errstate(invalid='ignore', divide='raise'):
for i in range(10000):
z = np.zeros(i)
try:
z / z
except(FloatingPointError) as exc:
print(exc, 'at size', i)
break
output:
divide by zero encountered in true_divide at size 8001
numpy version: 1.14.2
Seems like this bug was introduced just recently, as there is no such issue with 1.13.3
and 1.14.1
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (12 by maintainers)
Top Results From Across the Web
How to return 0 with divide by zero - Stack Overflow
In this case, it does the divide calculation anywhere 'where' b does not equal zero. When b does equal zero, then it remains...
Read more >NumPy 1.20.0 Release Notes
In the future, NumPy will raise an IndexError when an integer array index contains out of bound values even if a non-indexed dimension...
Read more >the absolute basics for beginners — NumPy v1.25.dev0 Manual
The NumPy library contains multidimensional array and matrix data structures (you'll find more information about this in later sections). It provides ndarray, a ......
Read more >NumPy quickstart — NumPy v1.24 Manual
A frequent error consists in calling array with multiple arguments, ... If an array is too large to be printed, NumPy automatically skips...
Read more >Chapter 4. NumPy Basics: Arrays and Vectorized Computation
This chapter will introduce you to the basics of using NumPy arrays, and should be sufficient for following along with the rest of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nowadays implementations of universal functions that use MKL VML has all been moved to
mkl_umath
package.The ufunc loops for certain types are registered with NumPy’s universal functions via
PyUFunc_RegisterLoopForType
.One can deregister these loops using
mkl_umath.restore()
.Yes, it is still reproducible:
It is coming from use of MKL VML function
vdDiv
used to perform division.One can turn errors off by using
mkl.set_vml_mode
:See https://software.intel.com/en-us/mkl-developer-reference-c-vmlsetmode for more details
You can restore the VML behavior with