[NumPy-Tickets] [NumPy] #1914: Delayed ValueError when using count_nonzero with object array

NumPy Trac numpy-tickets@scipy....
Mon Jul 25 05:51:40 CDT 2011


#1914: Delayed ValueError when using count_nonzero with object array
----------------------------------+-----------------------------------------
 Reporter:  rcl33                 |       Owner:  somebody
     Type:  defect                |      Status:  new     
 Priority:  normal                |   Milestone:  1.6.2   
Component:  numpy.core            |     Version:  1.6.0   
 Keywords:  object count_nonzero  |  
----------------------------------+-----------------------------------------
 Using count_nonzero on an array with dtype=numpy.object causes an error on
 the next logical test.

 Example:
 {{{
 import numpy

 x = numpy.zeros((3,), dtype=numpy.object)
 x[0] = numpy.zeros((30,))

 # This sets up the error
 numpy.count_nonzero(x)

 # A for loop or truth test triggers error
 for i in [1]: print i

 # Result is exception:
 # ValueError: The truth value of an array with more than one element is
 ambiguous. Use a.any() or a.all()
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1914>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list