Negative 2^63 when broadcasting np.inf into np.array
See original GitHub issuenumpy inf - when broadcasted into an integer Numpy Array - yields (-2 ^ 63).
Reproducing code example:
import numpy as np
mat1 = np.array([[0,1],[2,3]])
mat2 = np.array([[0.0,1.0],[2.0,3.0]])
mat1[:, 1] = np.inf
mat2[:, 1] = np.inf
out1 = np.min(mat1)
out2 = np.min(mat2)
print(out1, out2)
output on my machine: (-9223372036854775808, 0.0)
out1[0,1] is indeed -9223372036854775808
Numpy/Python version information:
1.18.1 3.7.6 (default, Jan 8 2020, 13:42:34) [Clang 4.0.1 (tags/RELEASE_401/final)]
Machine info:
Model Name: MacBook Pro Model Identifier: MacBookPro15,1 Processor Name: 8-Core Intel Core i9
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Broadcasting — NumPy v1.24 Manual
The term broadcasting describes how NumPy treats arrays with different shapes during arithmetic operations. Subject to certain constraints, the smaller ...
Read more >NumPy Basics: Arrays and Vectorized Computation
Since NumPy is a large topic, I will cover many advanced NumPy features like broadcasting in more depth later (see Appendix A). For...
Read more >Ignoring -Inf values in arrays using numpy/scipy in Python
When I take the log of negative entries, it returns -Inf, so I will have a matrix with some -Inf values as a...
Read more >NumPy: Set whether to print full or truncated ndarray - nkmk note
When outputting a NumPy array ndarray with print(), it may be truncated if the number of elements is large.You can control whether to...
Read more >jax.numpy package - JAX documentation - Read the Docs
Count number of occurrences of each value in array of non-negative ints. bitwise_and (x1, x2, /). Compute the bit-wise AND of two arrays...
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

(int) infis implementation-defined in C, which is where numpy gets its behavior from.Maybe a note about
np.array([np.inf]).astype(int)would be useful? Suggestions welcome but if not then I think this can be closed as sufficiently answered.