Hi,
The function bincount() counts the number of each value found in the
input array:
In [15]: numpy.bincount( array([1,3,3,3,4],dtype=int32) )
Out[15]: array([0, 1, 0, 3, 1])
According to the documentation, the input array must be non-negative
integers.
However an exception occurs when the input data type are unsigned integers
(which is an explicit guarantee of this non-negativity condition):
In [157]: numpy.bincount( array([1,3,3,3,4],dtype=uint32) )
TypeError: array cannot be safely cast to required type
This seems to be a bug.
Cheers
Stephen
P.S. I'm not familiar enough with the numpy source to track down where
this typechecking is done. But I did find a trivial typo in an error msg
in function arr_bincount() in numpy/lib/src/_compiled_base.c. The assert
message here has lost its initial 'F':
Py_Assert(numbers[mni] >= 0,
"irst argument of bincount must be non-negative");
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion