Ask Your Question
4

What is the reason for numpy's vectorize function to execute twice on the initial element?

asked 2023-06-26 06:21:19 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-26 06:49:01 +0000

huitzilopochtli gravatar image

The reason for numpy's vectorize function to execute twice on the initial element is that it first runs the function with a small temporary input array containing the first element of the original input array. This is done to determine the output data type and shape. Once this is determined, the function is then executed on the entire input array, including the first element. Therefore, the function ends up being executed twice on the initial element.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-26 06:21:19 +0000

Seen: 21 times

Last updated: Jun 26 '23