Open thouis opened 11 years ago
atmention:stefanv wrote on 2006-08-03
Can be improved by changing to NPY_UINTP, but that still won't allow 64-bit integers. Is there a way to easily fix this for 32-bit systems?
Milestone changed to 1.1
by atmention:alberts on 2007-05-12
Milestone changed to Unscheduled
by atmention:cournape on 2009-03-02
atmention:mwiebe wrote on 2011-03-23
This function still errors (with uint64 on a 64-bit machine). Bincount is a candidate to convert to using the iterator with buffering, since currently it will cause a copy if the input isn't contiguous and the right type.
atmention:bsouthey wrote on 2011-05-09
My C is not very good but hopefully someone with can correct the patch. The less obvious change (at least was to me) was that PyArray_ContiguousFromAny was being called with unsigned int, PyArray_INTP, rather than PyArray_UINTP.
According to the comment on the bincount code in "numpy/lib/src/_compiled_base.c", the first argument must be an array of non-negative integers (relevant lines):
* bincount accepts one, two or three arguments. The first is an array of
* non-negative integers The second, if present, is an array of weights,
Consequently I changed bincount to use unsigned ints instead of signed ints.
The patch is incorrect if the mxx and mnx functions can be used outside of bincount. In that case new functions would have to declared.
Attachment added by atmention:bsouthey on 2011-05-09: 0001-bincount-unsigned-ints.patch
Attachment added by atmention:bsouthey on 2011-05-09: 0002-Redo-bincount-signed-int-change.patch
atmention:bsouthey wrote on 2011-05-09
Okay, still was not that simple! I had to change one PyObject variable into PyArrayObject. This allowed to get the input dtype for PyArray?_ContiguousFromAny. Both patches need to be applied because I do not know how to get a single patch with git without redoing everything - sorry!
Original ticket http://projects.scipy.org/numpy/ticket/225 on 2006-08-03 by atmention:stefanv, assigned to atmention:teoliphant.
Under r2944: