np.uint64 + int == ... np.float64 ??
See original GitHub issueIs this behavior expected?
>>> print type(np.uint32(0) + int(0))
<type 'numpy.int64'>
>>> print type(np.uint64(0) + int(0))
<type 'numpy.float64'>
The latter took me by surprise!
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (13 by maintainers)
Top Results From Across the Web
Convert ndarray from float64 to integer - python - Stack Overflow
I'm using this arr in the following examples: >>> import numpy as np >>> arr = np.array([1, ...
Read more >Data types — NumPy v1.24 Manual
There are 5 basic numerical types representing booleans (bool), integers (int), unsigned integers (uint) floating point (float) and complex.
Read more >NumPy: Data types - w3resource
NumPy Data types: NumPy supports a much greater variety of ... integers (int), unsigned integers (uint) floating point (float) and complex.
Read more >NumPy: Cast ndarray to a specific dtype with astype()
List of basic data types ( dtype ) in NumPy ; uint64, u8, 64-bit unsigned integer ; float16, f2, 16-bit floating-point number ;...
Read more >Understanding Data Types in Python
NumPy Standard Data Types¶ ; uint64, Unsigned integer (0 to 18446744073709551615) ; float_, Shorthand for float64 . ; float16, Half precision float: sign...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
This behaviour also buged my program. Why it couldn’t simply overrun leaving responsibility for user. Casting silently to float64 is bad… If this is “normal” behaviour, it should be at least documented in official documentation.
Two other solutions:
int64 + int
returnint64
and similarlyuint64 + int
returnuint64
. Wrap and warn on overflow just like it does when adding homogenous types.int64 + int
return a dtype ofobject
and use Python’sint
.I prefer the first solution.