[NumPy-Tickets] [NumPy] #1487: vectorize(): result depends on execution order; is this normal?

NumPy Trac numpy-tickets@scipy....
Mon Jan 3 18:43:33 CST 2011


#1487: vectorize(): result depends on execution order; is this normal?
------------------------------+---------------------------------------------
 Reporter:  lebigot           |       Owner:  somebody
     Type:  defect            |      Status:  new     
 Priority:  normal            |   Milestone:  2.0.0   
Component:  numpy.core        |     Version:  1.3.0   
 Keywords:  vectorize, dtype  |  
------------------------------+---------------------------------------------

Comment(by jpeel):

 Replying to [comment:1 lebigot]:
 > Replying to [ticket:1487 lebigot]:
 > > I had understood from the documentation of vectorize(f) that the type
 of the first value returned by '''f''' instead determined the dtype of the
 returned array…
 >
 > PS: what I meant is that I thought, from the documentation, that the
 dtype of the returned array was determined ''each time'' by applying f on
 the first element of the (new) input arrays.

 I agree that the documentation certainly doesn't seem to indicate this
 behavior. I would have assumed exactly as you had assumed from what it
 says. The current behavior of vectorize is to leave the otypes attribute
 (output types) of the vectorize class instance empty if the otypes keyword
 isn't set in the call to vectorize. Then, when the first call to the
 vectorized function is made, otypes is set according to the input and will
 stay this way for all future calls (unless the otypes attribute is
 explicitly changed on the vectorize class instance).

 It really wouldn't be hard to change vectorize to work as currently
 described in the documentation. This would introduce some small slow down
 because the output type would have to be determined for each input.

 The other option is to change the documentation to accurately describe the
 vectorize behavior. It might be recommended to set the otypes keyword to
 avoid being surprised.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1487#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list