-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Description
When adding int 1
to a numpy {u}int array, usually a type conversion to int64 happens. This is normal. If, however, the type is uint64
, the array gets converted to float64
. I had not expected that. Perhaps it's correct though. Opinions?
MWE:
import numpy
a = numpy.array(0, dtype=int)
print((a + 1).dtype) # int64
a = numpy.array(0, dtype=numpy.uint16)
print((a + 1).dtype) # int64
a = numpy.array(0, dtype=numpy.uint32)
print((a + 1).dtype) # int64
a = numpy.array(0, dtype=numpy.uint64)
print((a + 1).dtype) # float64!
Metadata
Metadata
Assignees
Labels
No labels