[Scipy-tickets] [SciPy] #1254: ndimage.measurements.variance returns negative values sometimes

SciPy Trac scipy-tickets@scipy....
Wed Dec 1 00:12:32 CST 2010


#1254: ndimage.measurements.variance returns negative values sometimes
----------------------------+-----------------------------------------------
  Reporter:  thouis         |       Owner:  somebody
      Type:  defect         |      Status:  closed  
  Priority:  high           |   Milestone:  0.9.0   
 Component:  scipy.ndimage  |     Version:  0.7.0   
Resolution:  fixed          |    Keywords:          
----------------------------+-----------------------------------------------
Changes (by warren.weckesser):

  * status:  reopened => closed
  * resolution:  => fixed


Comment:

 Based on the comments in the code, it looks like part of the point of the
 if statement is to check whether `labels` has the correct data type to be
 used with bincount. The data type of the first argument to bincount must
 be safely castable to int; int8, int16, int32, uint8, and uint16 are OK,
 but int64, uint32 and uint64 are not. This means the test for being a
 subdtype of np.unsignedinteger is not strict enough. And, because
 issubtype(np.int64, np.int) is True, the original test was also not
 correct.

 The implication of the test is that it should be possible for the data
 type of `labels` to be something that is not compatible with bincount.
 This means there was a problem with r6836, which used bincount without
 checking that `labels` had a dtype that bincount could handle.

 I checked in a fix in r6893.  It includes a fix for #1242 also.

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


More information about the Scipy-tickets mailing list