[SciPy-Dev] small patch to scipy.ndimage.measurements
Thouis (Ray) Jones
thouis at broadinstitute.org
Mon Jul 19 17:04:57 EDT 2010
Lee Kamentsky noticed that ndimage.measurements has a too strict test
in _stats() and _select() that pushes it off the fast path when the
label matrix is a uint instead of an int.
I've filed a patch with ticket 1242 (which I can't get to right now,
for some reason). I include the patch below, as well:
Index: measurements.py
===================================================================
--- measurements.py (revision 6630)
+++ measurements.py (working copy)
@@ -298,7 +298,7 @@
# remap labels to unique integers if necessary, or if the largest
# label is larger than the number of values.
- if ((not numpy.issubdtype(labels.dtype, numpy.int)) or
+ if ((not numpy.issubdtype(labels.dtype, (numpy.int, numpy.uint))) or
(labels.min() < 0) or (labels.max() > labels.size)):
unique_labels, new_labels = numpy.unique1d(labels, return_inverse=True)
@@ -465,7 +465,7 @@
# remap labels to unique integers if necessary, or if the largest
# label is larger than the number of values.
- if ((not numpy.issubdtype(labels.dtype, numpy.int)) or
+ if ((not numpy.issubdtype(labels.dtype, (numpy.int, numpy.uint))) or
(labels.min() < 0) or (labels.max() > labels.size)):
# remap labels, and indexes
unique_labels, labels = numpy.unique1d(labels, return_inverse=True)
More information about the SciPy-Dev
mailing list