[Scipy-tickets] [SciPy] #599: unused code in ndimage.generate_binary_structure()

SciPy scipy-tickets@scipy....
Fri Feb 1 06:27:05 CST 2008


#599: unused code in ndimage.generate_binary_structure()
---------------------------+------------------------------------------------
 Reporter:  sebhaase       |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  normal         |   Milestone:  0.7     
Component:  scipy.ndimage  |     Version:          
 Severity:  normal         |    Keywords:          
---------------------------+------------------------------------------------
 See below: the line `output = numpy.zeros([3] * rank, bool)` is unused,
 since `output` gets overwritten right afterwards ....

 {{{
 def generate_binary_structure(rank, connectivity):
     """Generate a binary structure for binary morphological operations.

     The inputs are the rank of the array to which the structure will
     be applied and the square of the connectivity of the structure.
     """
     if connectivity < 1:
         connectivity = 1
     if rank < 1:
         if connectivity < 1:
             return numpy.array(0, dtype = bool)
         else:
             return numpy.array(1, dtype = bool)
     output = numpy.zeros([3] * rank, bool)
     output = numpy.fabs(numpy.indices([3] * rank) - 1)
     output = numpy.add.reduce(output, 0)
     return numpy.asarray(output <= connectivity, dtype = bool)
 }}}

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


More information about the Scipy-tickets mailing list