[Scipy-tickets] [SciPy] #1457: scipy.ndimage.measurements.standard_deviation does not work with sequence of indexs

SciPy Trac scipy-tickets@scipy....
Wed Jun 8 11:29:59 CDT 2011


#1457: scipy.ndimage.measurements.standard_deviation does not work with sequence
of indexs
---------------------------+------------------------------------------------
 Reporter:  sofoot         |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  normal         |   Milestone:          
Component:  scipy.ndimage  |     Version:  0.9.0   
 Keywords:                 |  
---------------------------+------------------------------------------------
 OS: Arch linux i686
 python version: 2.7
 numpy version: 1.5.1-2
 scipy version: 0.9.0-1

 source code:


 {{{
 import numpy as np
 from scipy import ndimage as NI

 a = np.array([[1,2,0,0],
               [5,3,0,4],
               [0,0,0,7],
               [9,3,0,0]])
 lbl, nlbl = NI.label(a)
 print NI.standard_deviation(a, lbl, index=np.arange(1, nlbl+1))
 }}}


 error message:

 {{{
 Traceback (most recent call last):
   File "testnd.py", line 20, in <module>
     print NI.standard_deviation(a, lbl, np.arange(1, nlbl+1))
   File "/usr/lib/python2.7/site-packages/scipy/ndimage/measurements.py",
 line 649, in standard_deviation
     return numpy.sqrt(variance(input, labels, index))
   File "/usr/lib/python2.7/site-packages/scipy/ndimage/measurements.py",
 line 596, in variance
     count, sum, sum_c_sq = _stats(input, labels, index, centered=True)
   File "/usr/lib/python2.7/site-packages/scipy/ndimage/measurements.py",
 line 434, in _stats
     sums_c = _sum_centered(labels.ravel())
   File "/usr/lib/python2.7/site-packages/scipy/ndimage/measurements.py",
 line 408, in _sum_centered
     centered_input = input - means[labels]
 ValueError: shape mismatch: objects cannot be broadcast to a single shape
 }}}


 The source comes from
 [http://docs.scipy.org/doc/scipy-0.9.0/reference/generated/scipy.ndimage.measurements.standard_deviation.html]

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


More information about the Scipy-tickets mailing list