[Scipy-tickets] [SciPy] #412: Broken Py_Statistics indexing

SciPy scipy-tickets@scipy....
Fri Jul 27 07:41:29 CDT 2007

#412: Broken Py_Statistics indexing
 Reporter:  stefan         |        Owner:  cdavid       
     Type:  defect         |       Status:  assigned     
 Priority:  normal         |    Milestone:  0.5.3 Release
Component:  scipy.ndimage  |      Version:  devel        
 Severity:  normal         |   Resolution:               
 Keywords:                 |  
Comment (by stefan):

 You reassigned the ticket, so I assume you want to work on it.

 In ndimage, labels and indices are similar, but not identical to, to
 masked arrays.  You assign labels to elements in an array, which can be
 used to limit the elements on which operations take place, e.g.

 x = N.array([1,2,3])

 which calculates the mean of all the elements labeled '5', i.e. something

 def mean(data,labels,index):
     N.mean(data[labels == index])

 It gets a bit more complicated when you define more than one index, but
 you get the idea.

 Unfortunately, the current implementation converts the index elements to
 long, which is unnecessary and causes problems.  Unnecessary, because all
 you need to do is to compare two objects -- there is no reason to
 specifically convert to long.  It also segfaults if you specify certain
 index values, e.g.

 ndi.mean(x, labels=[981729387123,9817239871987123,8971239871987123],

Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/412#comment:2>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.

More information about the Scipy-tickets mailing list