NumPy ufuncLesson 33Free preview
ufunc Create Function
This lesson is part of NumPy · All levels
Summary
If the built-in function is not enough, you can create your own ufunc with np.frompyfunc that accepts the ordinary Python function and applies it to the entire element array. Another alternative is np.vectorize which provides similar convenience. In addition, the .at method allows for value accumulation without a buffer, suitable for index-based accumulation.
Key points
- Np.frompyfunc(function, number_input, number_output) makes ufunc of the function itself.
- Np.vectorize provides a concise way to wrap up a regular Python function.
- The array, index, value) performs accumulation without buffering.
- Create a Ufunc when the element processing performance needs to be improved.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.