sum returns numpy.float64 when applied to a sequence of numpy.uint64
I came across this question on StackOverflow today: http://stackoverflow.com/questions/1...lements-of-a-g
I'm not familiar with `numpy` but I'm curious about this, so I started doing some experiments.
This is what I have discovered so far:
1. when a `generator ` is passed to `numpy.sum`, it fallback to use Python's built-in `sum`.
2. if elements of the sequence passed to `sum` is of type `numpy.uint64`, the result would be a number of type `numpy.float64`;
3. when I tried it with `numpy.int64`, the result is as expected: `numpy.int64`.
I guess the reason maybe that we don't really have `64 bits unsigned integer` in Python, so the numbers get converted to something different. And if so, I have no idea why it chose `float64` as the type.
|All times are GMT. The time now is 01:28 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.