[Numpy-tickets] [NumPy] #459: select does not preserve dtype for 1-element case

NumPy numpy-tickets@scipy....
Sat Mar 3 15:32:33 CST 2007


#459: select does not preserve dtype for 1-element case
-----------------------+----------------------------------------------------
 Reporter:  batripler  |       Owner:  somebody
     Type:  defect     |      Status:  new     
 Priority:  high       |   Milestone:          
Component:  numpy.lib  |     Version:  none    
 Severity:  normal     |    Keywords:          
-----------------------+----------------------------------------------------
 in lib/function_base.py/def select:

 421         if type(S) in ScalarType or max(asarray(S).shape)==1:
 422             pfac = asarray(1)
 423             for k in range(n2+1):
 424                 pfac = pfac + asarray(choicelist[k])
 425             S = S*ones(asarray(pfac).shape)

 the last line should preserve dtype:

 425             S = S*ones(asarray(pfac).shape, S.dtype)

 An example that works is:
   n=5; numpy.select([numpy.ones(n)>200],[numpy.ones(n)])
 An example that does not currently work, and should:
   n=1; numpy.select([numpy.ones(n)>200],[numpy.ones(n)])

 The patch is attached.

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/459>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list