-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Closed
Description
np.frompyfunc(lambda x,y:x+y,2,1).accumulate(np.arange(10))
raises an error:
ValueError: could not find a matching type for <lambda> (vectorized).accumulate, requested type has type code 'l'
accumulate
only works if the dtype
is set explicitly to object
(either in the input, the out
array, or as a kwarg
).
np.frompyfunc(lambda x,y:x+y,2,1).accumulate(np.arange(10,dtype=object))
This behavior may be consistent with the note in its doc
that The returned ufunc always returns PyObject arrays.
. Also when vectorize
uses a ufunc
generated by this function, it converts the args to object type, and then converts the output to a specified (or deduced) otype
.
However, is this error message required? A straight call of the ufunc
returns an object array without any warning or error message:
np.frompyfunc(lambda x:2*x,1,1)(np.arange(4))
# array([0, 2, 4, 6], dtype=object)
Or is this just documentation issue? Does its __doc__
need an added note?
Metadata
Metadata
Assignees
Labels
No labels