[Numpy-discussion] Does numpy.bincount support numpy.float128 type weights?

Nathan Goldbaum nathan12343 at gmail.com
Wed Nov 30 16:59:03 EST 2016


I think this is a deficiency in the current implementation of bincount,
which always casts the weights to float64. This WIP pull request should
probably fix it:

https://github.com/numpy/numpy/pull/7464

On Wed, Nov 30, 2016 at 3:54 PM, Wei, Huayi <weihuayi at xtu.edu.cn> wrote:

> Hi, There,
>
> Here is a sample code using `numpy.bincount`
>
>     import numpy as np
>     a = np.array([1.0, 2.0, 3.0], dtype=np.float128)
>     b = np.array([1, 2, 0], dtype=np.int)
>     c = np.bincount(b, weights=a)
>
> If run it, I get the following error report:
>
>     ----> 1 c = np.bincount(b, weights=a)
>     TypeError: Cannot cast array data from dtype('float128') to
> dtype('float64') according to the rule 'safe'
>
> Is it a bug of `np.bincount`? Does there exist any similar function which
> I can use to do the similar thing with numpy.float128 type weights?
>
> Best
>
> Huayi
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161130/96e66163/attachment.html>


More information about the NumPy-Discussion mailing list